|
1 | | -name: "Generate values.schema.json GitGuardian" |
| 1 | +name: "Generate values.schema.json" |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
29 | 29 | generate-schema: |
30 | 30 | runs-on: ubuntu-latest |
31 | 31 | timeout-minutes: 15 |
| 32 | + # Skip if the commit was made by github-actions bot to prevent infinite loops |
| 33 | + if: github.actor != 'github-actions[bot]' |
32 | 34 | permissions: |
33 | 35 | contents: write |
34 | 36 | pull-requests: write |
|
45 | 47 | python-version: '3.11' |
46 | 48 |
|
47 | 49 | - name: Set up Helm |
48 | | - uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 |
| 50 | + uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1 |
49 | 51 | with: |
50 | 52 | version: 'v3.19.2' |
51 | 53 |
|
@@ -214,27 +216,48 @@ jobs: |
214 | 216 | echo " has_changes: ${{ steps.check-changes.outputs.has_changes }}" |
215 | 217 | echo " Should commit to main: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' && steps.check-changes.outputs.has_changes == 'true' }}" |
216 | 218 |
|
217 | | - - name: Commit and push schema updates (push to main) |
| 219 | + - name: Create PR for schema updates (push to main) |
218 | 220 | if: | |
219 | 221 | (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && |
220 | 222 | github.ref == 'refs/heads/main' && |
221 | 223 | steps.check-changes.outputs.has_changes == 'true' |
| 224 | + env: |
| 225 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
222 | 226 | run: | |
223 | 227 | git config user.name 'github-actions[bot]' |
224 | 228 | git config user.email 'github-actions[bot]@users.noreply.github.com' |
225 | 229 |
|
| 230 | + # Create a new branch for the schema updates |
| 231 | + BRANCH_NAME="auto/schema-update-$(date +%s)" |
| 232 | + git checkout -b "$BRANCH_NAME" |
| 233 | +
|
226 | 234 | git add charts/*/values.schema.json |
227 | 235 |
|
228 | 236 | git commit -m "chore: auto-generate values.schema.json for updated charts" \ |
229 | 237 | -m "Automatically generated JSON schemas for Helm values files." \ |
230 | 238 | -m "" \ |
231 | 239 | -m "Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>" |
232 | 240 |
|
233 | | - # Pull latest changes and rebase |
234 | | - git pull --rebase origin main |
| 241 | + # Push the branch |
| 242 | + git push origin "$BRANCH_NAME" |
| 243 | +
|
| 244 | + # Create a pull request |
| 245 | + gh pr create \ |
| 246 | + --title "chore: auto-generate values.schema.json" \ |
| 247 | + --body "This PR contains automatically generated JSON schemas for Helm values files. |
| 248 | +
|
| 249 | + ## Changes |
| 250 | + - Auto-generated \`values.schema.json\` files for charts with updated \`values.yaml\` |
| 251 | +
|
| 252 | + ## Notes |
| 253 | + - This PR was automatically created by the schema generation workflow |
| 254 | + - Please review and merge if the changes look correct |
| 255 | + - The workflow will not run again on this bot's commits to prevent loops |
235 | 256 |
|
236 | | - # Push changes |
237 | | - git push origin main |
| 257 | + --- |
| 258 | + 🤖 Generated by [generate-schema workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" \ |
| 259 | + --base main \ |
| 260 | + --head "$BRANCH_NAME" |
238 | 261 |
|
239 | 262 | - name: Commit schema updates to PR branch |
240 | 263 | if: | |
|
0 commit comments