Skip to content

ci: publish main commit tag to ghcr.io/coder/coder-preview #8897

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 19 commits into from
Aug 4, 2023
Merged
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ jobs:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -724,6 +725,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Linux amd64 Docker image
id: build_and_push
run: |
set -euxo pipefail
go mod download
Expand All @@ -738,3 +740,21 @@ jobs:
--version $version \
--push \
build/coder_linux_amd64

# Get commit sha to be used as package tag
new_package_tag=$(gh api repos/coder/coder/commits/main | jq -r '.sha[0:7]')

# Tag image with new package tag and push
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$new_package_tag
docker push ghcr.io/coder/coder-preview:main-$new_package_tag

- name: Prune old images
uses: vlaurin/action-ghcr-prune@v0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: coder
container: coder-preview
keep-younger-than: 7 # days
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will delete all old image tags older than 7 days that does not start with pr e.g. pr1234 and will delete images that start with main- i.e. main-632hst52

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@matifali matifali Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will also not delete custom pushed tags like gvisor-fix

keep-tags-regexes: ^pr
prune-tags-regexes: ^main-
prune-untagged: true