-
Notifications
You must be signed in to change notification settings - Fork 6k
fix(ci): build+push image in release flow #3838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,28 @@ | ||
name: docker | ||
|
||
on: | ||
# Shows the manual trigger in GitHub UI | ||
# helpful as a back-up in case the GitHub Actions Workflow fails | ||
workflow_dispatch: | ||
|
||
release: | ||
types: [published] | ||
|
||
jobs: | ||
docker-images: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Run ./ci/steps/build-docker-image.sh | ||
run: ./ci/steps/build-docker-image.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,12 +1,37 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# See if this version already exists on Docker Hub. | ||
function version_exists() { | ||
local output | ||
output=$(curl --silent "https://index.docker.io/v1/repositories/codercom/code-server/tags/$VERSION") | ||
if [[ $output == "Tag not found" ]]; then | ||
return 1 | ||
else | ||
return 0 | ||
fi | ||
} | ||
|
||
main() { | ||
cd "$(dirname "$0")/../.." | ||
|
||
# ci/lib.sh sets VERSION and provides download_artifact here | ||
source ./ci/lib.sh | ||
|
||
mkdir -p release-images | ||
docker buildx bake -f ci/release-image/docker-bake.hcl | ||
if version_exists; then | ||
echo "$VERSION is already pushed" | ||
return | ||
fi | ||
|
||
# Download the release-packages artifact | ||
download_artifact release-packages ./release-packages | ||
|
||
# Login to Docker | ||
if [[ ${CI-} ]]; then | ||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
fi | ||
|
||
docker buildx bake -f ci/release-image/docker-bake.hcl --push | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Legend! So much better. |
||
} | ||
|
||
main "$@" |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this file? Maybe
build-and-push-docker-image.sh
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did consider this but felt it was a bit of a mouthful - though am not opposed to it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem a bit long haha but I don't want to mislead anyone who might try to run this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could maybe shorten to
docker-buildx-push.sh
or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great!