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(helm): auto public Helm chart after PR merged #7526

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

Conversation

afdesk
Copy link
Contributor

@afdesk afdesk commented Sep 17, 2024

Description

Trivy publishes a new Helm Chart only for major versions (ex 0.55.0).

This PR suggests next workflow:

  • if there are any changes in helm folder ('helm/trivy/**'), the test will be run.

  • if a new tag is pushed will be created a new PR with update a new version of Helm Chart.

  • Helm Chart will be published, after the PR with new version is merged.
    The action runs helm test before publishing again to check that everything is still OK
    (ex. Trivy image wasn't removed).

Tests with mage command

I've tested this update in my fork:

Refs:

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@afdesk afdesk marked this pull request as ready for review September 18, 2024 05:57
@afdesk afdesk requested review from DmitriyLewen, itaysk and knqyf263 and removed request for knqyf263 September 18, 2024 05:57
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

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

Hello @afdesk

I left a comments.

Do you have a test action in your fork? If yes, please add a link to this run in the PR description.

Trivy publishes a new Helm Chart only for major versions (ex 0.55.0).

I didn't find conditions for that.

.github/workflows/publish-chart.yaml Show resolved Hide resolved
misc/helm-chart/create-pr.sh Outdated Show resolved Hide resolved
.github/workflows/publish-chart.yaml Show resolved Hide resolved
@afdesk
Copy link
Contributor Author

afdesk commented Sep 18, 2024

Trivy publishes a new Helm Chart only for major versions (ex 0.55.0).

I didn't find conditions for that.

This condition works only for major version, because backport branch usually doesn't contain a Helm Chart update.

publish-chart:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'

@DmitriyLewen
Copy link
Contributor

This condition works only for major version, because backport branch usually doesn't contain a Helm Chart update.

Oh... You said current behavior. I thought it was new logic.
then I have no questions about it

@DmitriyLewen
Copy link
Contributor

a new PR: afdesk#72

IIUC author of PR should be aqua-bot (as for backport (e.g. #7521))

@afdesk
Copy link
Contributor Author

afdesk commented Sep 19, 2024

a new PR: afdesk#72

IIUC author of PR should be aqua-bot (as for backport (e.g. #7521))

it seems it depends on token owner, because I tried to keep the same workflow:

- name: Set up Git user
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Run backport script
run: ./misc/backport/backport.sh ${{ env.BRANCH_NAME }} ${{ github.event.issue.number }}
env:
# Use ORG_REPO_TOKEN instead of GITHUB_TOKEN
# This allows the created PR to trigger tests and other workflows
GITHUB_TOKEN: ${{ secrets.ORG_REPO_TOKEN }}

@afdesk
Copy link
Contributor Author

afdesk commented Sep 19, 2024

I had concerns about label (lifecycle/active) and about versions (that chart version is equal trivy version now).

@itaysk @knqyf263 wdyt? thanks

@DmitriyLewen
Copy link
Contributor

it seems it depends on token owner

you said this and I realized that most likely you are right and I have already encountered this 👍

@knqyf263
Copy link
Collaborator

label (lifecycle/active)

Do we need a label?

about versions (that chart version is equal trivy version now).

They should be different; otherwise, we can't update the chart version when we fix the Helm chart itself.

@afdesk afdesk marked this pull request as draft October 17, 2024 11:47
@afdesk afdesk marked this pull request as ready for review October 17, 2024 13:04
@afdesk
Copy link
Contributor Author

afdesk commented Oct 17, 2024

@knqyf263 @DmitriyLewen I've updated a version changing.
Could you take a look at this PR again when you have time?
thanks a lot!

return result
}

func newHelmVersion(currentHelm, currentTrivy, newTrivy string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 1e4b16c

magefiles/helm.go Outdated Show resolved Hide resolved
magefiles/helm.go Outdated Show resolved Hide resolved
magefiles/helm.go Outdated Show resolved Hide resolved
publish-chart:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
Copy link
Contributor

Choose a reason for hiding this comment

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

I may be wrong, but I remember that the events for merging a PR by default and merging using merge queue may be different.
Does this work correctly?

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.

3 participants