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
Prev Previous commit
Next Next commit
prune by filtering
  • Loading branch information
matifali committed Aug 4, 2023
commit 49be52e7f79f9f90bc283ea92676f4635de987ac
23 changes: 11 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -746,18 +746,17 @@ jobs:
new_package_tag=$(gh api /repos/coder/coder/commits/main | jq -r '.sha[:8]')

# Tag image with new package tag and push
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:$new_package_tag
docker push ghcr.io/coder/coder-preview:$new_package_tag
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

# Get old package tag
previous_package_tag=$(gh api /repos/coder/coder/commits/main | jq -r '.parents[0].sha[:8]')
echo "previous_package_tag=$previous_package_tag" >> GITHUB_OUTPUT

- name: Delete image
continue-on-error: true
uses: bots-house/ghcr-delete-image-action@v1.1.0
- name: Prune old images
uses: vlaurin/action-ghcr-prune@v0.5.0
with:
owner: coder
name: coder-preview
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.build_and_push.outputs.previous_package_tag }}
organization: coder
container: coder-preview
dry-run: true
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