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

github: Build and publish Docker image on release #12734

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Conversation

bep
Copy link
Member

@bep bep commented Aug 9, 2024

Fixes #10760

@bep bep mentioned this pull request Aug 9, 2024
@bep bep force-pushed the feat/dockerimageaction branch from 012f262 to 87f1fc9 Compare August 9, 2024 08:00
@bep
Copy link
Member Author

bep commented Aug 9, 2024

@morremeyer a question;

Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/gohugoio/hugo: failed to authorize: failed to fetch anonymous token: unexpected status from GET request to https://ghcr.io/token?scope=repository%3Agohugoio%2Fhugo%3Apull%2Cpush&service=ghcr.io: 403 Forbidden

Copy link
Contributor

@morremeyer morremeyer left a comment

Choose a reason for hiding this comment

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

@bep The GITHUB_TOKEN that gets injected is enough, since the packages:write permission is set in https://github.com/gohugoio/hugo/pull/12734/files#diff-113df80dfdb383808d66c98190c3f60ea45745427f926da3b04f572ff081d8a6R13-R14.

I use it in the same way in https://github.com/community-tooling/oci-images/blob/5b78318d705c60ff3fd66dca827041f98ee18c7a/.github/workflows/build.yml.

What I forgot in this PR is to remove the if condition to log in only on tags, which should not be set here.

With the suggestions, this will now build and push for branches & PRs as defined in https://github.com/docker/metadata-action#typeref:

  • For a branch, the image tag will be the branch name
  • For a tag, the image tag will be the tag name

If you want, I can go through the different scenarios on my fork to verify them.

.github/workflows/image.yml Outdated Show resolved Hide resolved
.github/workflows/image.yml Outdated Show resolved Hide resolved
.github/workflows/image.yml Outdated Show resolved Hide resolved
@bep
Copy link
Member Author

bep commented Aug 9, 2024

If you want, I can go through the different scenarios on my fork to verify them.

No, that's fine. I need to understand this setup myself, and a little trying-and-failing helps ...

@morremeyer
Copy link
Contributor

Feel free to ping me for anything related to the image in the future, too - I'll use the image myself, so this will be a nice way to contribute back.

@bep bep force-pushed the feat/dockerimageaction branch from 39aefa2 to 9ee683e Compare August 9, 2024 10:06
@bep bep force-pushed the feat/dockerimageaction branch from 9ee683e to 4b516c3 Compare August 9, 2024 11:20
@bep
Copy link
Member Author

bep commented Aug 9, 2024

@morremeyer I had to add this commit to make the build green: 4b516c3 ... makes sense to you?

I'm doing a Hugo release on either Monday or Tuesday, in which we'll see if the publishing part works ...

@morremeyer
Copy link
Contributor

That works, but we might end up with layers/images that are never published, since we build on push of changes to the Dockerfile or the workflow and then never merge these images, if it's not a tag.

My suggestion in #12734 (comment) should fix that while still merging for all relevant events.

I also realized that we need to run for tags, not only for pushes, so I opened a second suggestion for that with #12734 (comment).

@bep
Copy link
Member Author

bep commented Aug 9, 2024

I also realized that we need to run for tags, not only for pushes,

Good catch, added ...

@bep bep force-pushed the feat/dockerimageaction branch from cf57eb5 to 3370887 Compare August 9, 2024 13:42
@bep bep force-pushed the feat/dockerimageaction branch from 748f381 to cff2630 Compare August 9, 2024 14:26
@bep bep merged commit ceed812 into master Aug 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create and publish official Docker images
3 participants