55 github-token : # id of input
66 description : ' GitHubのトークン。'
77 required : true
8- repo-name :
9- description : ' リポジトリ名。 `pull_request` 以外のトリガーも設定している場合はリポジトリ名を決め打ちで入力。'
10- required : true
118 branch-name-prefix :
129 description : ' branch名の接頭語。'
1310 required : true
@@ -20,10 +17,6 @@ inputs:
2017 description : ' 本文の接頭語。'
2118 required : true
2219 default : " "
23- base-branch :
24- description : ' ベースブランチ。 `pull_request` 以外のトリガーの場合は決め打ちで入力。'
25- required : false
26- default : " "
2720runs :
2821 using : " composite"
2922 steps :
@@ -36,45 +29,30 @@ runs:
3629 # 差分があったときは、コミットを作りpushする
3730 - name : Push
3831 env :
39- HEAD_REF : ${{github.event.pull_request.head.ref}}
32+ HEAD_REF : ${{github.event.pull_request.head.ref || github.ref_name }}
4033 PR_TITLE_PREFIX : ${{inputs.pr-title-prefix}}
4134 AUTHOR : ${{github.actor}}
4235 GITHUB_TOKEN : ${{inputs.github-token}}
4336 REPOSITORY : ${{github.repository}}
4437 BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
45- BASE_BRANCH : ${{inputs.base-branch}}
46- if : inputs.repo-name == github.repository && steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
38+ if : steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
4739 run : ${{ github.action_path }}/scripts/action/push.sh
4840 shell : bash
4941 - name : Set org name
5042 uses : actions/github-script@v6.3.3
51- if : inputs.repo-name == github.repository && (github. event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
43+ if : github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
5244 id : set_org_name
5345 with :
5446 github-token : ${{inputs.github-token}}
5547 result-encoding : string
5648 script : |
5749 const script = require('${{ github.action_path }}/scripts/action/set_org_name.js')
5850 return script()
59- - name : Get HEAD_REF
60- uses : actions/github-script@v6.3.3
61- env :
62- HEAD_REF : ${{github.event.pull_request.head.ref}}
63- BASE_BRANCH : ${{inputs.base-branch}}
64- if : inputs.repo-name == github.repository
65- id : get_head_ref
66- with :
67- github-token : ${{inputs.github-token}}
68- result-encoding : string
69- script : |
70- const script = require('${{ github.action_path }}/scripts/action/get_head_ref.js')
71- return script()
7251 - name : Get PullRequests
7352 uses : actions/github-script@v6.3.3
74- if : inputs.repo-name == github.repository && steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
53+ if : steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
7554 id : get_pull_requests
7655 env :
77- HEAD_REF : ${{steps.get_head_ref.outputs.result}}
7856 ORG_NAME : ${{steps.set_org_name.outputs.result}}
7957 BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
8058 with :
8563 # pushしたブランチでPRを作る
8664 - name : Create PullRequest
8765 uses : actions/github-script@v6.3.3
88- if : inputs.repo-name == github.repository && steps.diff.outputs.result != '' && steps.get_pull_requests.outputs.result == 0 && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
66+ if : steps.diff.outputs.result != '' && steps.get_pull_requests.outputs.result == 0 && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
8967 id : create_pull_request
9068 env :
91- HEAD_REF : ${{steps.get_head_ref.outputs.result}}
9269 ORG_NAME : ${{steps.set_org_name.outputs.result}}
9370 PR_DESCRIPTION_PREFIX : ${{inputs.pr-description-prefix}}
9471 PR_NUMBER : ${{github.event.pull_request.number}}
10178 return await script({github, context})
10279 - name : Assign a user
10380 uses : actions/github-script@v6.3.3
104- if : inputs.repo-name == github.repository && 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]'
81+ 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]'
10582 env :
10683 PR_NUMBER : ${{steps.create_pull_request.outputs.result}}
10784 ASSIGN_USER : ${{github.event.pull_request.user.login}}
11390 # 既にformat修正のPRがある状態で、手動でformatを修正した場合、format修正のPRを閉じる
11491 - name : Close PullRequest
11592 uses : actions/github-script@v6.3.3
116- if : inputs.repo-name == github.repository && (( github.event_name == 'pull_request' && (github.event.action == 'closed' || steps.diff.outputs.result == '')) || ((github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && steps.diff.outputs.result == '') )
93+ if : ( github.event_name == 'pull_request' && (github.event.action == 'closed' || steps.diff.outputs.result == '')) || ((github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && steps.diff.outputs.result == '')
11794 env :
118- HEAD_REF : ${{steps.get_head_ref.outputs.result}}
11995 ORG_NAME : ${{steps.set_org_name.outputs.result}}
12096 BRANCH_NAME_PREFIX : ${{inputs.branch-name-prefix}}
12197 with :
0 commit comments