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

Conversation

matifali
Copy link
Member

@matifali matifali commented Aug 4, 2023

This will publish 2 tags ghcr.io/coder/coder-preview:main and ghcr.io/coder/coder-preview:main-shortsha on each merge to main.
Also, it will prune ghcr.io/coder/coder-preview for all previous tags that are older than 7 days while preserving any pr1234 tags and custom tags like gvisor-fix.

@matifali matifali requested a review from deansheather August 4, 2023 08:05
@matifali matifali marked this pull request as ready for review August 4, 2023 08:06
Comment on lines 752 to 754
# 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
Copy link
Member

Choose a reason for hiding this comment

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

This isn't robust because on failure we will fail to delete old tags. This should be changed to find all old tags on the registry using the API and delete commits older than a couple of days/weeks or something. Deleting commits immediately means that new replicas will fail to pull on new nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. So something like if it is older than 7 days?
Also as this package also hosts pr1234 tags and some tags like gvisor-fix that we do not want to delete, so I opted for deleting only a specific tag as filtering will include more complexity

Copy link
Member

Choose a reason for hiding this comment

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

You could also push to a public gcr.io dir instead for better safety, we could make a project on our billing account and add the CI's service account to have permissions to manage images in that project on artifact registry

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.

Hmm. I want to keep it here for now to reduce further complexity. I will try to develop a more robust way to delete all old tags. Thanks for the feedback.

@matifali matifali requested a review from deansheather August 4, 2023 09:18
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

@matifali matifali changed the title ci: publish main commit tag to ghcr.io/coder/coder-preview ci: publish main commit tag to ghcr.io/coder/coder-preview Aug 4, 2023
@matifali matifali requested review from deansheather and removed request for deansheather August 4, 2023 15:48
@deansheather
Copy link
Member

I had a stale review from earlier that I forgot to approve, disregard the comments

@matifali matifali merged commit 9f5ac4d into main Aug 4, 2023
@matifali matifali deleted the matifali/publish-commit-tag branch August 4, 2023 16:27
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants