feat(helm): add auto-environment values to k8s-reporter chart (#1031) #197
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: helm chart | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'charts/**' | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Generate token | |
| id: generate_token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ vars.CI_SIGNED_COMMIT_APP_ID }} | |
| private-key: ${{ secrets.CI_SIGNED_COMMIT_APP_PRIVATE_KEY }} | |
| - uses: actions/checkout@v7 | |
| with: | |
| token: ${{ steps.generate_token.outputs.token }} | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v5 | |
| with: | |
| version: 'latest' | |
| - name: Lint | |
| run: make helm-lint | |
| - name: Setup Helm Docs | |
| uses: gabe565/setup-helm-docs-action@d5c35bdc9133cfbea3b671acadf50a29029e87c2 # v1.0.4 | |
| with: | |
| version: 'latest' # v1.14.2 | |
| - name: Generate Helm Docs | |
| run: | | |
| cd charts/k8s-reporter | |
| helm-docs --template-files README.md.gotmpl,_templates.gotmpl --output-file README.md | |
| - name: Helm Package | |
| run: helm package charts/k8s-reporter --destination package | |
| # Configure AWS credentials | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v6 | |
| with: | |
| role-to-assume: arn:aws:iam::358426185766:role/cli | |
| aws-region: eu-central-1 | |
| role-duration-seconds: 2400 | |
| role-session-name: ${{ github.event.repository.name }} | |
| - name: Copy old index.yaml from S3 to merge it with the new one | |
| run: | | |
| aws s3 cp s3://kosli-helm-charts-repo/stable/k8s-reporter/index.yaml package/old-index.yaml | |
| - name: Helm regenerate repo index | |
| run: helm repo index package/. --url https://charts.kosli.com/ --merge package/old-index.yaml | |
| - name: Upload new chart and the update index.yaml to S3 | |
| run: | | |
| rm package/old-index.yaml | |
| aws s3 cp --recursive package s3://kosli-helm-charts-repo/stable/k8s-reporter/ | |
| - name: cleanup | |
| run: | | |
| rm -rf package | |
| - name: Create branch via GitHub API | |
| run: | | |
| MAIN_SHA=$(gh api repos/${{ github.repository }}/git/ref/heads/main --jq '.object.sha') | |
| gh api repos/${{ github.repository }}/git/refs \ | |
| -X POST \ | |
| -f ref='refs/heads/helm-docs-update' \ | |
| -f sha="$MAIN_SHA" || \ | |
| gh api repos/${{ github.repository }}/git/refs/heads/helm-docs-update \ | |
| -X PATCH \ | |
| -f sha="$MAIN_SHA" \ | |
| -F force=true || echo "Branch may already exist" | |
| env: | |
| GH_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| - name: Commit and push changes | |
| uses: planetscale/ghcommit-action@v0.2.22 | |
| with: | |
| commit_message: 'Update helm docs' | |
| repo: ${{ github.repository }} | |
| branch: helm-docs-update | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| - name: Create Pull Request | |
| run: | | |
| gh pr create \ | |
| --title "Update helm docs" \ | |
| --body "Update helm docs" \ | |
| --base main \ | |
| --head helm-docs-update || echo "PR may already exist" | |
| env: | |
| GH_TOKEN: ${{ steps.generate_token.outputs.token }} |