Skip to content
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

ci: Add image labels, merge publish to Docker Hub/GHCR workflows #954

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

tigattack
Copy link
Contributor

Summary

This PR merges the currently separate workflows for publishing to Docker Hub and GHCR. It also adds labels to the built images as a good best-practice enhancement.

My personal motivation for this was originally adding labels to allow Renovate to track the origin of an update to the image in my repo and embed changelogs. It's able to do this thanks to the standardised OCI labels which this PR adds.

Whilst doing this, I thought a nice enhancement would be to merge the separate workflows for Docker Hub/GHCR pushes, since I couldn't see a reason for their separation. Let me know if I've missed a use case for this or the change is otherwise undesirable, and I can strip this PR back to just add labels to built images.

Example of generated labels in the context of the publish-release workflow:

"org.opencontainers.image.created": "2025-01-04T02:02:34.878Z",
"org.opencontainers.image.description": "⛑ Automated developer-oriented status page",
"org.opencontainers.image.licenses": "Apache-2.0",
"org.opencontainers.image.revision": "d69844dc1320be2e3e927900a204a9793b2c59eb",
"org.opencontainers.image.source": "https://github.com/TwiN/gatus",
"org.opencontainers.image.title": "gatus",
"org.opencontainers.image.url": "https://github.com/TwiN/gatus",
"org.opencontainers.image.version": "v5.15.0"

And an example of generated tags in the same context:

"twinproduction/gatus:v5.15.0",
"twinproduction/gatus:stable",
"twinproduction/gatus:latest",
"ghcr.io/twin/gatus:v5.15.0",
"ghcr.io/twin/gatus:stable",
"ghcr.io/twin/gatus:latest"

Checklist

  • Tested and/or added tests to validate that the changes work as intended, if applicable.
  • Updated documentation in README.md, if applicable.

@tigattack tigattack changed the title Merge publish to Docker Hub/GHCR workflows and add image labels ci: Add image labels, merge publish to Docker Hub/GHCR workflows Jan 4, 2025
@TwiN TwiN added the feature New feature or request label Jan 6, 2025
Copy link
Owner

@TwiN TwiN left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you for the contribution!

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.04%. Comparing base (8aae277) to head (a2ddf85).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #954   +/-   ##
=======================================
  Coverage   76.04%   76.04%           
=======================================
  Files          74       74           
  Lines        6704     6704           
=======================================
  Hits         5098     5098           
  Misses       1304     1304           
  Partials      302      302           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TwiN TwiN merged commit b650518 into TwiN:master Jan 6, 2025
2 checks passed
@TwiN
Copy link
Owner

TwiN commented Jan 6, 2025

@tigattack Hmm, do you have any idea why, when I docker inspect twinproduction/gatus:experimental, I'm not seeing the labels you mentioned this PR should add?

$ docker pull twinproduction/gatus:experimental
#...
$ docker inspect twinproduction/gatus:experimental
#...
        "Config": {
            //...
            "Labels": null
        },
#...

P.S. This was from the publish-experimental workflow, not the publish-latest or publish-release workflows.

@tigattack
Copy link
Contributor Author

@TwiN it seems like the publish-experimental job hasn't yet been run on a branch which includes these changes. If you trigger it from master, or do a rebase/merge on fix/icmp to pull my changes in from master, and then trigger the job, it should build an image including the labels.

@tigattack tigattack deleted the ci/merge_publish_workflows_add_labels branch January 6, 2025 15:29
@TwiN
Copy link
Owner

TwiN commented Jan 6, 2025

Ah good point, I forgot the experimental image was on a much older branch 🤦
Thanks again!

@tigattack
Copy link
Contributor Author

No worries, glad I could help 😄

@TwiN
Copy link
Owner

TwiN commented Jan 8, 2025

Just to confirm, all good with the latest latest image:

            "Labels": {
                "org.opencontainers.image.created": "2025-01-08T03:27:00.063Z",
                "org.opencontainers.image.description": "⛑ Automated developer-oriented status page",
                "org.opencontainers.image.licenses": "Apache-2.0",
                "org.opencontainers.image.revision": "c259364edf0f2edb2ac93db1256b1ad5a1a8992e",
                "org.opencontainers.image.source": "https://github.com/TwiN/gatus",
                "org.opencontainers.image.title": "gatus",
                "org.opencontainers.image.url": "https://github.com/TwiN/gatus",
                "org.opencontainers.image.version": "latest"
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants