Release v0.2.11: Fix SSH key authentication for private repositories #15
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: Release Helm Chart | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Chart version to release (leave empty to use Chart.yaml version)" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| pages: write | |
| jobs: | |
| release-helm-chart: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: main | |
| - name: Configure Git | |
| run: | | |
| git config user.name "$GITHUB_ACTOR" | |
| git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
| - name: Install Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: "v3.14.0" | |
| - name: Extract version from tag or input | |
| id: get_version | |
| run: | | |
| if [ "${{ github.event_name }}" = "push" ]; then | |
| # Tag push: extract version from tag | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| elif [ -n "${{ inputs.version }}" ]; then | |
| # Manual dispatch with version input | |
| VERSION="${{ inputs.version }}" | |
| else | |
| # Manual dispatch without input: read from Chart.yaml | |
| VERSION=$(grep '^version:' helm/ansible-inspec/Chart.yaml | awk '{print $2}' | tr -d '"') | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "📦 Releasing Helm chart version: $VERSION" | |
| - name: Update Helm chart dependencies | |
| run: | | |
| helm dependency update helm/ansible-inspec/ | |
| - name: Package Helm chart | |
| run: | | |
| helm package helm/ansible-inspec/ -d helm/ | |
| echo "✅ Chart packaged successfully" | |
| ls -lh helm/ansible-inspec-*.tgz | |
| # Copy chart to temp location for GitHub release | |
| mkdir -p /tmp/helm-release | |
| cp helm/ansible-inspec-*.tgz /tmp/helm-release/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| files: | | |
| /tmp/helm-release/ansible-inspec-${{ steps.get_version.outputs.version }}.tgz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Checkout gh-pages branch | |
| run: | | |
| # Save current directory state | |
| pwd | |
| ls -la helm/ || echo "helm directory not found" | |
| # Clean up any untracked files that might conflict | |
| git clean -fd helm/ || echo "No files to clean" | |
| # Remove any existing chart files that might conflict | |
| rm -f helm/ansible-inspec-*.tgz || echo "No chart files to remove" | |
| # Reset any staged changes | |
| git reset --hard HEAD || echo "Nothing to reset" | |
| # Fetch latest gh-pages | |
| git fetch origin gh-pages | |
| # Force checkout gh-pages (overwrite any conflicts) | |
| git checkout --force gh-pages | |
| # Ensure helm directory exists | |
| mkdir -p helm | |
| # Restore chart file for gh-pages | |
| cp /tmp/helm-release/ansible-inspec-*.tgz helm/ | |
| # Verify the file was copied | |
| ls -la helm/ansible-inspec-*.tgz | |
| - name: Update Helm repository index | |
| run: | | |
| helm repo index helm --url https://htunn.github.io/ansible-inspec/helm --merge helm/index.yaml | |
| echo "✅ Updated Helm repository index" | |
| - name: Display index changes | |
| run: | | |
| echo "📋 Current charts in repository:" | |
| cat helm/index.yaml | grep "version:" | head -10 | |
| - name: Commit and push to gh-pages | |
| run: | | |
| git add helm/ | |
| git commit -m "Release Helm chart ${{ steps.get_version.outputs.version }} | |
| - Add packaged chart: ansible-inspec-${{ steps.get_version.outputs.version }}.tgz | |
| - Update Helm repository index | |
| - Published from tag: ${{ github.ref_name }} | |
| Auto-generated by GitHub Actions" | |
| git push origin gh-pages | |
| echo "✅ Published to GitHub Pages" | |
| - name: Summary | |
| run: | | |
| echo "## 🎉 Helm Chart Release Complete!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tag:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 📦 Installation" >> $GITHUB_STEP_SUMMARY | |
| echo '```bash' >> $GITHUB_STEP_SUMMARY | |
| echo "helm repo add ansible-inspec https://htunn.github.io/ansible-inspec/helm" >> $GITHUB_STEP_SUMMARY | |
| echo "helm repo update" >> $GITHUB_STEP_SUMMARY | |
| echo "helm install my-release ansible-inspec/ansible-inspec --version ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY | |
| echo "- [Helm Repository](https://htunn.github.io/ansible-inspec/helm)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [Chart Package](https://htunn.github.io/ansible-inspec/helm/ansible-inspec-${{ steps.get_version.outputs.version }}.tgz)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [Artifact Hub](https://artifacthub.io/packages/search?repo=ansible-inspec)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### ⏱️ Next Steps" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Verify chart is available: \`helm search repo ansible-inspec\`" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Artifact Hub will auto-index the new version (~5-10 minutes)" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Check Artifact Hub: https://artifacthub.io/packages/search?repo=ansible-inspec" >> $GITHUB_STEP_SUMMARY |