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

Add metadata-action so labels are generated #426

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

halkeye
Copy link

@halkeye halkeye commented Apr 26, 2024

I use renovate to make sure my deployed apps are up to date. (halkeye/home-k8s#116) and according to the documentation if the source docker label is set, it'll actually pull in the release notes.

I checked the latest release, and it doesn't seem to have the labels (or any labels) set, so using the pre-existing github action should populate all the nice metadata.

regctl image config --format '{{ jsonPretty .Config.Labels }}' ghcr.io/matrix-org/sliding-sync
null

Pull Request Checklist

Copy link
Member

@kegsay kegsay left a comment

Choose a reason for hiding this comment

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

I don't know enough about this which is why it's taken me a while to look into this.

I'll need you to walk me through your changes and justify them. Thanks.

@@ -58,9 +56,8 @@ jobs:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: |
ghcr.io/${{ env.GHCR_NAMESPACE }}/sliding-sync:latest
Copy link
Member

Choose a reason for hiding this comment

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

We seem to be losing the :latest tag..?

Copy link
Author

Choose a reason for hiding this comment

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

So the latest tag is no longer specified by docker/build-push-action@v4, but a list of tags (in this case I think only one) is created by docker/metadata-action@v5

See

${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) && 'type=raw,value=latest' }}

It'll create main on main branch, latest on release, and then always a sha specific tag

with:
cache-from: type=gha
cache-to: type=gha,mode=max
Copy link
Member

Choose a reason for hiding this comment

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

We seem to lose the caching..?

Copy link
Author

Choose a reason for hiding this comment

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

I feel like this diff is just because i merged them into the one docker/build-push-action@v4

Though that being said, i think the if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') should be removed so its always pushing an email? or did you only want images pushed for releases? its been a few weeks.

Copy link
Author

Choose a reason for hiding this comment

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

No wait yes, the if: should be removed so it always builds the image, but maybe the push: true could be made into a conditional so only pushes the result sometimes?

@halkeye
Copy link
Author

halkeye commented Jun 6, 2024

I'll need you to walk me through your changes and justify them. Thanks.

Yea thats cool, i'm only just starting to learn about labels because of my k8s lab.

I think the diff is making it more confusing than it should be too.

@halkeye
Copy link
Author

halkeye commented Jun 6, 2024

Fixed a typo, it now runs
https://github.com/halkeye/sliding-sync/actions/runs/9395229608/job/25874257317 for example output on a branch (just builds, no push)

Example version - v0.0.1
https://github.com/halkeye/sliding-sync/actions/runs/9395286907/job/25874424720
https://github.com/halkeye/sliding-sync/pkgs/container/halkeye%2Fsliding-sync

(I have a bug cause one tag is "false")

* any branch this workflow runs for will get a tag
* any pr this workflow runs for will get a tag
* github tags will get a tag (semver pattern raw)
* a sha tag will be created
* latest tag will be created if its a tag
@halkeye
Copy link
Author

halkeye commented Jun 6, 2024

image
https://github.com/halkeye/sliding-sync/actions/runs/9395428499
https://github.com/halkeye/sliding-sync/pkgs/container/halkeye%2Fsliding-sync/226245448?tag=latest

regctl image config --format '{{ jsonPretty .Config.Labels }}' ghcr.io/halkeye/halkeye/sliding-sync:latest
{
  "org.opencontainers.image.created": "2024-06-06T05:08:55.274Z",
  "org.opencontainers.image.description": "Proxy implementation of MSC3575's sync protocol.",
  "org.opencontainers.image.licenses": "Apache-2.0",
  "org.opencontainers.image.revision": "5f014bff281a49d1a4213dd3be20190a413a7a9f",
  "org.opencontainers.image.source": "https://github.com/halkeye/sliding-sync",
  "org.opencontainers.image.title": "sliding-sync",
  "org.opencontainers.image.url": "https://github.com/halkeye/sliding-sync",
  "org.opencontainers.image.version": "v0.0.2"
}

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

Successfully merging this pull request may close these issues.

2 participants