1+ name : Auto Tag Chart Release on PR Merge
2+
3+ on :
4+ pull_request :
5+ types : [closed]
6+ branches : [main]
7+
8+ jobs :
9+ auto-tag :
10+ name : Create Chart Release Tag
11+ if : |
12+ github.event.pull_request.merged == true &&
13+ contains(github.event.pull_request.labels.*.name, 'chart-update')
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0
21+
22+ - name : Extract chart info from PR
23+ id : extract
24+ run : |
25+ PR_TITLE="${{ github.event.pull_request.title }}"
26+ PR_BRANCH="${{ github.event.pull_request.head.ref }}"
27+
28+ # Extract chart name and version from branch name
29+ # Format: update-vault-transit-unseal-operator-1.0.5
30+ if [[ "$PR_BRANCH" =~ ^update-([a-zA-Z0-9-]+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
31+ CHART_NAME="${BASH_REMATCH[1]}"
32+ APP_VERSION="${BASH_REMATCH[2]}"
33+ echo "chart_name=$CHART_NAME" >> $GITHUB_OUTPUT
34+ echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
35+
36+ # Get the chart version from Chart.yaml
37+ CHART_VERSION=$(yq '.version' "./charts/$CHART_NAME/Chart.yaml")
38+ echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT
39+
40+ echo "Chart: $CHART_NAME"
41+ echo "Chart Version: $CHART_VERSION"
42+ echo "App Version: $APP_VERSION"
43+ else
44+ echo "ERROR: Could not parse chart info from PR branch: $PR_BRANCH"
45+ exit 1
46+ fi
47+
48+ - name : Create and push tag
49+ run : |
50+ git config --global user.name "github-actions[bot]"
51+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
52+
53+ TAG_NAME="${{ steps.extract.outputs.chart_name }}-v${{ steps.extract.outputs.chart_version }}"
54+
55+ # Check if tag already exists
56+ if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
57+ echo "Tag $TAG_NAME already exists, skipping..."
58+ exit 0
59+ fi
60+
61+ # Create and push tag
62+ git tag -a "$TAG_NAME" -m "Release ${{ steps.extract.outputs.chart_name }} v${{ steps.extract.outputs.chart_version }}
63+
64+ Chart version : ${{ steps.extract.outputs.chart_version }}
65+ App version : ${{ steps.extract.outputs.app_version }}
66+
67+ Automated release from PR # ${{ github.event.pull_request.number }}"
68+
69+ git push origin "$TAG_NAME"
70+
71+ echo "✅ Created tag : $TAG_NAME"
72+
73+ - name : Comment on PR
74+ if : success()
75+ uses : peter-evans/create-or-update-comment@v4
76+ with :
77+ issue-number : ${{ github.event.pull_request.number }}
78+ body : |
79+ 🎉 **Chart Release Tag Created!**
80+
81+ Tag: `${{ steps.extract.outputs.chart_name }}-v${{ steps.extract.outputs.chart_version }}`
82+
83+ The Helm chart release workflow will now automatically:
84+ - Package the chart
85+ - Update the repository index
86+ - Create a GitHub release
87+ - Publish to https://fredericrous.github.io/charts/
88+
89+ Monitor progress: [Release Workflow](https://github.com/fredericrous/charts/actions/workflows/helm-release.yaml)
0 commit comments