Upgrade finops-agent and chart to 1.0.14 (#83) #67
Workflow file for this run
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: Publish Helm Chart | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: "main" | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "github-actions[bot]@noreply.example.com" | |
| git config --local user.name "github-actions[bot]" | |
| - name: Install Helm | |
| uses: azure/setup-helm@v3 | |
| with: | |
| version: v3.12.0 | |
| - name: Update chart version | |
| run: | | |
| # Extract version from tag (remove 'v' prefix) | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| # Update Chart.yaml | |
| sed -i "s/^version: .*/version: $VERSION/" charts/finops-agent/Chart.yaml | |
| - name: Create packages directory | |
| run: | | |
| mkdir -p .cr-release-packages | |
| - name: Package Helm chart | |
| run: | | |
| cd charts/finops-agent | |
| helm package . --dependency-update -d ../../.cr-release-packages/ | |
| - name: Check if Chart.yaml or Chart.lock changed | |
| id: chart_changed | |
| run: | | |
| git fetch origin main | |
| if git diff --quiet origin/main -- charts/finops-agent/Chart.yaml charts/finops-agent/Chart.lock; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit updated files | |
| if: steps.chart_changed.outputs.changed == 'true' | |
| run: | | |
| git add charts/finops-agent/Chart.yaml charts/finops-agent/Chart.lock | |
| git commit -m "Update chart version to ${{ github.ref_name }}" | |
| git push origin main | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: gh-pages | |
| - name: Configure Git | |
| run: | | |
| cd gh-pages | |
| git config --local user.email "github-actions[bot]@noreply.example.com" | |
| git config --local user.name "github-actions[bot]" | |
| - name: Update index | |
| run: | | |
| # Copy existing index if it exists | |
| if [ -f gh-pages/index.yaml ]; then | |
| cp gh-pages/index.yaml .cr-release-packages/ | |
| fi | |
| # Merge new chart into index | |
| helm repo index .cr-release-packages --url https://github.com/kubecost/finops-agent-chart/releases/download/${{ github.ref_name }} --merge .cr-release-packages/index.yaml | |
| - name: Copy index | |
| run: | | |
| cp .cr-release-packages/index.yaml gh-pages/ | |
| - name: Commit and push | |
| run: | | |
| cd gh-pages | |
| git add index.yaml | |
| git commit -m "Update chart index for ${{ github.ref_name }}" | |
| git push origin gh-pages | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: .cr-release-packages/*.tgz | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| - name: Notify Release | |
| uses: slackapi/slack-github-action@v2.1.1 | |
| with: | |
| webhook-type: webhook-trigger | |
| payload: | | |
| { | |
| "workflow": "${{github.workflow}}", | |
| "version": "${{ github.ref_name }}", | |
| "message": "Released version ${{ github.ref_name }} of the finops-agent-chart" | |
| } | |
| webhook: ${{ secrets.SLACK_WEBHOOK_FINOPS_CHART_RELEASE }} |