-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Build and publish container in CI
* Check that container builds on PR * Publish container from master branch
- Loading branch information
Showing
8 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CI Design guidelines | ||
|
||
* Keep as much of scripting as possible in scripts and outside of github action yaml files | ||
* The docker image is rebuilt if the `Dockerfile` or `.containerversion` file is modified. | ||
* If there are changes in the `Dockerfile`, then `.containerversion` must be updated with an | ||
unpublished version number. | ||
* When there are changes to `Dockerfile` and `.containerversion` the master branch job will | ||
publish that version as the latest to docker hub. | ||
* On pull request events github will checkout a version of the tree that is PR branch merged into | ||
the base branch. When we look for what is modifed we can diff HEAD^1 to HEAD. | ||
|
||
o-----o <-- Pull requst branch | ||
/ \ | ||
o--o--o------o <-- (HEAD) | ||
\ | ||
github.base_ref (base being merged into, typically master) | ||
|
||
* On push events we get hashes of last commit before and after the push. And the last commit after | ||
is checked out. When we look for what changed we can diff github.event.before to HEAD. | ||
|
||
o--o--o------o <-- github.event.after (HEAD) | ||
\ | ||
github.event.before |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
CONTAINER_REPO=shiftcrypto/firmware_v2 | ||
CONTAINER_VERSION=$(cat .containerversion) | ||
|
||
docker build --no-cache --platform linux/amd64,linux/arm64 -t $CONTAINER_REPO:latest -t $CONTAINER_REPO:$CONTAINER_VERSION . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
# This script works on merge commits. <rev>^1 means the first parent of <rev>. | ||
# | ||
# When the github action creates a temporary merge commit for a pull request, the first parent will | ||
# be the base (the branch being merged into). | ||
|
||
set -e | ||
|
||
if git diff --name-only HEAD^1 HEAD | grep -E '^(\.containerversion|Dockerfile)' >/dev/null; then | ||
echo "modified=true" | ||
exit | ||
fi | ||
echo "modified=false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
CONTAINER_REPO=shiftcrypto/firmware_v2 | ||
CONTAINER_VERSION=$(cat .containerversion) | ||
|
||
# docker manifest returns 1 (error) if the container doesn't exist and 0 (success) if it does. | ||
if docker manifest inspect $CONTAINER_REPO:$CONTAINER_VERSION > /dev/null; then | ||
>&2 echo Container version \'$CONTAINER_VERSION\' exists. | ||
echo container-published=true | ||
exit | ||
fi | ||
echo container-published=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
CONTAINER_REPO=shiftcrypto/firmware_v2 | ||
CONTAINER_VERSION=$(cat .containerversion) | ||
|
||
docker push $CONTAINER_REPO:latest | ||
docker push $CONTAINER_REPO:$CONTAINER_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters