Skip to content

Commit ecc57a8

Browse files
authored
Open pull request automatically when code are generated by openapi generator (#532)
github acitons doesn't support `push to change to protected branch`... - https://github.com/orgs/community/discussions/25305 - https://github.com/orgs/community/discussions/13836 - https://stackoverflow.com/questions/74128344/github-protected-branch-hook-declined-even-with-allow-force-pushes Thus we need to approve pull request created by github actions.
1 parent e9e1ce1 commit ecc57a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.github/workflows/commit-generated-code.yml renamed to .github/workflows/generated-code.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Commit generated code to master branch
1+
name: Generate code and open pull request
22

33
on:
44
workflow_dispatch:
@@ -24,12 +24,15 @@ jobs:
2424
python generate-code.py
2525
diff=$(git --no-pager diff --name-only HEAD)
2626
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
27+
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
2728
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
2829
run: |
2930
git config user.name github-actions
3031
git config user.email github-actions@github.com
32+
git checkout -b update-diff-${{ env.CURRENT_DATETIME }}
3133
git add .
3234
git commit -m "Code are generated by openapi generator"
33-
git push origin master
35+
git push origin update-diff-${{ env.CURRENT_DATETIME }}
36+
gh pr create -B ${{ github.ref_name }} -t "Codes are generated by openapi generator" -b "" --label "line-openapi-update"
3437
env:
3538
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)