1818 generate-api-data :
1919 if : " !contains(github.event.head_commit.message, 'Update autogenerated JSON files')"
2020 runs-on : ubuntu-latest
21+ # Permissions needed to create PR and write content
22+ permissions :
23+ contents : write
24+ pull-requests : write
2125
2226 steps :
2327 - name : Checkout code
@@ -39,28 +43,75 @@ jobs:
3943 run : |
4044 npm run generate-json-api
4145
42- - name : Commit and push if there are any changes
43- working-directory : ./projects/composition
44- run : |
45- git config user.name github-actions
46- git config user.email [email protected] 47- git pull origin master
48- git add ./src/app/api-data
49- if [[ -n "$(git status --porcelain)" ]]; then
50- git commit -m "Update autogenerated JSON files"
51- git push origin HEAD:master
52- fi
46+ # Instead of direct commit/push, create a PR
47+ - name : Create Pull Request
48+ id : cpr
49+ uses : peter-evans/create-pull-request@v6
50+ with :
51+ token : ${{ secrets.GITHUB_TOKEN }}
52+ # More descriptive commit message
53+ commit-message : ' chore: Update API documentation JSON files'
54+ # Use bot account for better tracking
55+ committer : github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
56+ author : github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
57+ # Unique branch name using run number to avoid conflicts
58+ branch : api-docs-update-${{ github.run_number }}
59+ # Auto-delete branch after merge
60+ delete-branch : true
61+ title : ' chore: Update API documentation JSON files'
62+ # Detailed PR description with context
63+ body : |
64+ ## Auto-generated API Documentation Update
65+
66+ This PR contains automatically generated API documentation files.
67+
68+ ### Changes
69+ - Updated JSON API files based on latest component changes
70+
71+ ### Workflow Run
72+ - Triggered by commit: ${{ github.sha }}
73+ - Run ID: ${{ github.run_id }}
74+
75+ ---
76+
77+ 🤖 This PR was automatically created by the documentation workflow.
78+ # Labels for organization and to skip changelog
79+ labels : |
80+ documentation
81+ automated
82+ skip-changelog
83+
84+ # Auto-merge the PR (requires repo settings to allow auto-merge)
85+ - name : Enable Pull Request Automerge
86+ if : steps.cpr.outputs.pull-request-operation == 'created'
87+ uses : peter-evans/enable-pull-request-automerge@v3
88+ with :
89+ token : ${{ secrets.GITHUB_TOKEN }}
90+ pull-request-number : ${{ steps.cpr.outputs.pull-request-number }}
91+ merge-method : squash
92+
93+ # Auto-approve the PR so it can be merged
94+ - name : Auto approve PR
95+ if : steps.cpr.outputs.pull-request-operation == 'created'
96+ uses : hmarr/auto-approve-action@v4
97+ with :
98+ github-token : ${{ secrets.GITHUB_TOKEN }}
99+ pull-request-number : ${{ steps.cpr.outputs.pull-request-number }}
53100
54101 # Build job
55102 build :
56103 runs-on : ubuntu-latest
57104 needs : generate-api-data
105+ # Only run if generate-api-data succeeded or was skipped (not failed)
106+ if : always() && (needs.generate-api-data.result == 'success' || needs.generate-api-data.result == 'skipped')
58107
59108 steps :
60109 - name : Checkout code
61110 uses : actions/checkout@v4
62111 with :
63112 ssh-key : ${{ secrets.DEPLOY_KEY }}
113+ # Explicitly checkout master to get latest changes after PR merge
114+ ref : master
64115
65116 - name : Fetch latest commits
66117 run : git pull origin master
@@ -104,6 +155,8 @@ jobs:
104155 # Deploy job
105156 deploy :
106157 needs : build
158+ # Only deploy if build succeeded
159+ if : success()
107160
108161 permissions :
109162 pages : write
0 commit comments