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

Merged
merged 31 commits into from
Oct 25, 2024

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 "[email protected]"
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!

magefiles/helm.go Outdated Show resolved Hide resolved
magefiles/helm.go Outdated Show resolved Hide resolved
magefiles/helm.go Outdated Show resolved Hide resolved
magefiles/helm.go Outdated Show resolved Hide resolved
.github/workflows/publish-chart.yaml Show resolved Hide resolved
Comment on lines 68 to 70
tempFile, err := ioutil.TempFile("", "Chart-*.yaml")
assert.NoError(t, err)
defer os.Remove(tempFile.Name())
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for info:
You can use t.TempDir() to avoid having to do defer os.Remove(tempFile.Name()).

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 f309ab1

magefiles/helm_test.go Outdated Show resolved Hide resolved
.github/workflows/publish-chart.yaml Show resolved Hide resolved
.github/workflows/publish-chart.yaml Outdated Show resolved Hide resolved
@afdesk
Copy link
Contributor Author

afdesk commented Oct 24, 2024

@DmitriyLewen Could take another look at this PR? thank

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.

LGTM

@knqyf263 knqyf263 added this pull request to the merge queue Oct 25, 2024
Merged via the queue into aquasecurity:main with commit a16b830 Oct 25, 2024
12 checks passed
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