- Notifications
You must be signed in to change notification settings - Fork924
ci: build a multi-arch image on each commit tomain
#11544
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
30 commits Select commitHold shift + click to select a range
cfe0ddc
wip
matifalib13efd7
`fmt`
matifali131a227
wip
matifali88102bd
Merge branch 'main' into multi-arch-main
matifali206a11c
wip
matifalicef4eb7
add condition to not push
matifalibcbafce
enable push and pull for base image
matifali1332c94
update project
matifali7894508
Tagged Docker image as main
matifalie9d2421
use free runner
matifali568560c
do not push
matifali30e9470
use larger runner
matifali8dd78cd
wip
matifali29e43e9
do not build base
matifali3d28596
remove excess permission
matifali0d1233b
cleanup
matifali5caf911
wip
matifali71e8145
test
matifali65678a7
test
matifalid3ee831
test
matifali6816e10
Update Docker image tags and retention policy
matifali4116e94
cleanup
matifali8b39c8b
Add prune-tags-regexes to CI workflow
matifali6fbfcb6
prune intermediate images for each arch.
matifali9f5725d
Merge branch 'main' into multi-arch-main
matifali7c91a25
prevent tags cleanup and artifact upload on PR branches
matifaliec5cd53
Merge branch 'main' into multi-arch-main
matifalie48d0c9
pr suggestions
matifalidc07bef
Merge branch 'main' into multi-arch-main
matifali319ffa1
PR commnets
matifaliFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
60 changes: 42 additions & 18 deletions.github/workflows/ci.yaml
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 |
---|---|---|
@@ -655,7 +655,7 @@ jobs: | ||
# to main branch. We are only building this for amd64 platform. (>95% pulls | ||
# are for amd64) | ||
needs: changes | ||
if: needs.changes.outputs.docs-only == 'false' && !github.event.pull_request.head.repo.fork | ||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||
@@ -692,46 +692,70 @@ jobs: | ||
go mod download | ||
version="$(./scripts/version.sh)" | ||
tag="main-$(echo "$version" | sed 's/+/-/g')" | ||
echo "tag=$tag" >> $GITHUB_OUTPUT | ||
make gen/mark-fresh | ||
make -j \ | ||
build/coder_linux_{amd64,arm64,armv7} \ | ||
build/coder_"$version"_windows_amd64.zip \ | ||
build/coder_"$version"_linux_amd64.{tar.gz,deb} | ||
- name: Build Linux Dockerimages | ||
id: build-docker | ||
env: | ||
CODER_IMAGE_BASE: ghcr.io/coder/coder-preview | ||
CODER_IMAGE_TAG_PREFIX: main | ||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||
run: | | ||
set -euxo pipefail | ||
# build Docker images for each architecture | ||
version="$(./scripts/version.sh)" | ||
tag="main-$(echo "$version" | sed 's/+/-/g')" | ||
echo "tag=$tag" >> $GITHUB_OUTPUT | ||
# build images for each architecture | ||
make -j build/coder_"$version"_linux_{amd64,arm64,armv7}.tag | ||
matifali marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
matifali marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# only push if we are on main branch | ||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then | ||
# build and push multi-arch manifest, this depends on the other images | ||
# being pushed so will automatically push them | ||
make -j push/build/coder_"$version"_linux_{amd64,arm64,armv7}.tag | ||
matifali marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# Define specific tags | ||
tags=("$tag" "main" "latest") | ||
# Create and push a multi-arch manifest for each tag | ||
# we are adding `latest` tag and keeping `main` for backward | ||
# compatibality | ||
for t in "${tags[@]}"; do | ||
./scripts/build_docker_multiarch.sh \ | ||
--push \ | ||
--target "ghcr.io/coder/coder-preview:$t" \ | ||
--version $version \ | ||
$(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag) | ||
done | ||
fi | ||
- name: Prune old images | ||
if: github.ref == 'refs/heads/main' | ||
uses: vlaurin/action-ghcr-prune@v0.5.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
organization: coder | ||
container: coder-preview | ||
keep-younger-than: 7 # days | ||
keep-tags: latest | ||
keep-tags-regexes: ^pr | ||
prune-tags-regexes: | | ||
^main- | ||
^v | ||
prune-untagged: true | ||
- name: Upload build artifacts | ||
if: github.ref == 'refs/heads/main' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coder | ||
8 changes: 7 additions & 1 deletionscripts/image_tag.sh
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
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.