@@ -42,38 +42,37 @@ runs:
4242 - name : Set HEAD_REF
4343 shell : bash
4444 run : echo "HEAD_REF=${{github.event.pull_request.head.ref || github.ref_name}}" >>"${GITHUB_ENV}"
45+ - name : Set env
46+ id : set-env
47+ shell : bash
48+ run : |
49+ echo "PR_DESCRIPTION_PREFIX=${{inputs.pr-description-prefix}}" >> "$GITHUB_ENV"
50+ echo "PR_NUMBER=${{github.event.pull_request.number}}" >> "$GITHUB_ENV"
51+ echo "PR_TITLE_PREFIX=${{inputs.pr-title-prefix}}" >> "$GITHUB_ENV"
52+ echo "BRANCH_NAME_PREFIX=${{inputs.branch-name-prefix}}" >> "$GITHUB_ENV"
4553 # 差分があったときは、コミットを作りpushする
4654 - name : Push
4755 env :
48- PR_TITLE_PREFIX : ${{inputs.pr-title-prefix}}
4956 TOKEN : ${{inputs.github-token}}
50- BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
5157 NO_VERIFY : ${{inputs.no-verify}}
5258 if : steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch')
5359 working-directory : ${{inputs.working-directory}}
5460 run : ${{ github.action_path }}/scripts/action/push.sh
5561 shell : bash
56- - name : Get PullRequests
62+ - name : Get a number of PullRequests
5763 uses : actions/github-script@v7.0.1
5864 if : steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch')
59- id : get_pull_requests
60- env :
61- BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
65+ id : get_number_of_pull_requests
6266 with :
6367 github-token : ${{inputs.github-token}}
6468 script : |
65- const script = require('${{ github.action_path }}/scripts/action/get_pull_requests .js')
69+ const script = require('${{ github.action_path }}/scripts/action/get_number_of_pull_requests .js')
6670 return await script({github, context})
6771 # pushしたブランチで修正PRを作る
6872 - name : Create PullRequest
6973 uses : actions/github-script@v7.0.1
70- if : steps.diff.outputs.result != '' && steps.get_pull_requests .outputs.result == 0 && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch')
74+ if : steps.diff.outputs.result != '' && steps.get_number_of_pull_requests .outputs.result == 0 && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch')
7175 id : create_pull_request
72- env :
73- PR_DESCRIPTION_PREFIX : ${{inputs.pr-description-prefix}}
74- PR_NUMBER : ${{github.event.pull_request.number}}
75- PR_TITLE_PREFIX : ${{inputs.pr-title-prefix}}
76- BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
7776 with :
7877 github-token : ${{inputs.github-token}}
7978 script : |
@@ -82,20 +81,28 @@ runs:
8281 # 元のPRを出したユーザーを修正PRにアサインする
8382 - name : Assign a user
8483 uses : actions/github-script@v7.0.1
85- if : steps.diff.outputs.result != '' && steps.get_pull_requests .outputs.result == 0 && github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.user.login != 'renovate[bot]'
84+ if : steps.diff.outputs.result != '' && steps.get_number_of_pull_requests .outputs.result == 0 && github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.user.login != 'renovate[bot]'
8685 env :
8786 PR_NUMBER : ${{steps.create_pull_request.outputs.result}}
8887 with :
8988 github-token : ${{inputs.github-token}}
9089 script : |
9190 const script = require('${{ github.action_path }}/scripts/action/assign_a_user.js')
9291 await script({github, context})
92+ # 修正PRのタイトルやDescriptionを更新する
93+ - name : Update PullRequest
94+ uses : actions/github-script@v7.0.1
95+ if : steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch')
96+ id : update_pull_request
97+ with :
98+ github-token : ${{inputs.github-token}}
99+ script : |
100+ const script = require('${{ github.action_path }}/scripts/action/update_pull_request.js')
101+ return await script({github, context})
93102 # 既に修正PRがある状態で、手動でformatを修正した場合、修正PRを閉じる
94103 - name : Close PullRequest
95104 uses : actions/github-script@v7.0.1
96105 if : (github.event_name == 'pull_request' && (github.event.action == 'closed' || steps.diff.outputs.result == '')) || ((github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch') && steps.diff.outputs.result == '')
97- env :
98- BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
99106 with :
100107 github-token : ${{inputs.github-token}}
101108 script : |
0 commit comments