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

Upload Helm chart as OCI artifact to GCHR #44

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

jacksgt
Copy link
Contributor

@jacksgt jacksgt commented Oct 20, 2023

Hi @maelvls ,

as discussed in #41 , I'm adding the functionality to automatically update and push the Helm chart as an OCI artifact to Github's container registry.

Please give it a try since I'm not familiar with the usual release process and goreleaser - feel free to make changes as necessary.

@jetstack-bot jetstack-bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 20, 2023
@jetstack-bot jetstack-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 20, 2023
.goreleaser.yaml Outdated
# package Helm
- helm package ./deploy/chart --version {{ trimprefix .Version "v"}} --app-version {{ .Version }}
# upload Helm chart as OCI artifact to GitHub Container Registry
- '{{if .IsSnapshot}}echo SKIPPING: {{end}}helm push ./openshift-routes-{{ trimprefix .Version "v"}}.tgz oci://ghcr.io/cert-manager/cert-manager-openshift-routes:{{ .Version }}-chart'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the repo path ok or should we use a subpath (ghcr.io/cert-manager/cert-manager-openshift-routes/chart:{{ trimprefix .Version "v" }})?

Copy link
Member

@maelvls maelvls Dec 4, 2023

Choose a reason for hiding this comment

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

I'd suggest going with an organization-wide subpath: ghcr.io/cert-manager/charts. If we go with:

Suggested change
- '{{if .IsSnapshot}}echo SKIPPING: {{end}}helm push ./openshift-routes-{{ trimprefix .Version "v"}}.tgz oci://ghcr.io/cert-manager/cert-manager-openshift-routes:{{ .Version }}-chart'
- '{{if .IsSnapshot}}echo SKIPPING: {{end}}helm push ./openshift-routes-{{ trimprefix .Version "v"}}.tgz oci://ghcr.io/cert-manager/charts'

then the charts will be pushed to the following registry path:

oci://ghcr.io/cert-manager/charts/openshift-routes
                                  <-------------->
                                 added by helm push

That's because helm push uses the name of the chart (here, openshift-routes) to know where to push. Do you mind if I push a commit to test it out?

By the way, I noticed that the Helm chart is named openshift-routes in Chart.yaml, but the container image is named cert-manager-openshift-routes. Should we rename the Helm chart in Chart.yaml?

Copy link
Member

@maelvls maelvls Dec 4, 2023

Choose a reason for hiding this comment

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

I pushed a commit and tagged it with v0.4.0-alpha.0 to test it out. I was getting 403 Forbidden when helm chart was being run. I realized that's because I needed to "attach" the registry https://github.com/cert-manager/openshift-routes/pkgs/container/charts%2Fopenshift-routes to this repository, which I did via the UI by clicking "Manage Actions access" and I selected "cert-manager/openshift-routes" with "Role: Write". I detailed this problem in https://hackmd.io/@maelvls/fixing-403-forbidden-ghcr.

Copy link
Member

Choose a reason for hiding this comment

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

@jacksgt It works now! The action job 19293897798 is all green. I haven't made the Helm chart OCI registry public yet since I'm not sure about the Helm chart name yet.

Should we go with

ghcr.io/cert-manager/charts/openshift-routes

or

ghcr.io/cert-manager/charts/cert-manager-openshift-routes

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the fix!

I'd go with ghcr.io/cert-manager/charts/openshift-routes, since the Helm chart itself is called openshift-routes: https://github.com/cert-manager/openshift-routes/blob/main/deploy/chart/Chart.yaml#L2

Copy link
Member

@maelvls maelvls Dec 15, 2023

Choose a reason for hiding this comment

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

Agreed. It makes sense to call the chart after the GitHub repository.

I hope that the inconsistence between the container image name and the Helm chart name won't be a problem 😅

@jetstack-bot jetstack-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 20, 2023
@jacksgt
Copy link
Contributor Author

jacksgt commented Nov 17, 2023

@maelvls Please take a look when you get some time.

@jetstack-bot jetstack-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 4, 2023
@maelvls
Copy link
Member

maelvls commented Dec 14, 2023

It's all good to go!

/approve
/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 14, 2023
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maelvls

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 14, 2023
@jetstack-bot jetstack-bot merged commit ab27c68 into cert-manager:main Dec 14, 2023
3 of 4 checks passed
@maelvls
Copy link
Member

maelvls commented Dec 15, 2023

I merged your changes. Thank you for doing this!!

I'll release v0.4.0 now!

Update: The Helm chart can be used like this:

helm upgrade --install openshift-routes oci://ghcr.io/cert-manager/charts/openshift-routes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants