@@ -73,21 +73,31 @@ runs:
7373 github-token : ${{inputs.github-token}}
7474 result-encoding : string
7575 script : return process.env.GITHUB_REPOSITORY.split('/')[0]
76- - name : Get PullRequests
76+ - name : Get HEAD_REF
77777878 env :
7979 HEAD_REF : ${{github.event.pull_request.head.ref}}
80- 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')
81- id : get_pull_requests
80+ if : inputs.repo-name == github.repository
81+ id : get_head_ref
8282 with :
8383 github-token : ${{inputs.github-token}}
84+ result-encoding : string
8485 script : |
8586 let HEAD_REF = process.env["HEAD_REF"]
8687
8788 if (HEAD_REF === "" && "${{inputs.base-branch}}" !== "") {
88- HEAD_REF = "${{inputs.base-branch}}"
89+ return "${{inputs.base-branch}}"
8990 }
9091
92+ return HEAD_REF
93+ - name : Get PullRequests
94+ 95+ 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')
96+ id : get_pull_requests
97+ with :
98+ github-token : ${{inputs.github-token}}
99+ script : |
100+ const HEAD_REF = "${{steps.get_head_ref.outputs.result}}"
91101 let head = "${{steps.set_org_name.outputs.result}}:${{inputs.branch-name-prefix}}"
92102
93103 if (HEAD_REF != "") {
@@ -108,38 +118,52 @@ runs:
108118 # pushしたブランチでPRを作る
109119 - name : Create PullRequest
110120111- env :
112- HEAD_REF : ${{github.event.pull_request.head.ref}}
113121 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')
114122 id : create_pull_request
115123 with :
116124 github-token : ${{inputs.github-token}}
117125 script : |
118- let HEAD_REF = process.env["HEAD_REF"]
126+ const HEAD_REF = "${{steps.get_head_ref.outputs.result}}"
127+ let head = "${{inputs.branch-name-prefix}}"
119128
120- if (HEAD_REF === "" && "${{inputs.base-branch}}" != = "") {
121- HEAD_REF = "${{inputs.base-branch}}"
129+ if (HEAD_REF ! = "") {
130+ head + = "-" + HEAD_REF
122131 }
123132
133+ const head_with_repo = `${{steps.set_org_name.outputs.result}}:${head}`
124134 let title = "${{inputs.pr-title-prefix}}"
125135 let body = "${{inputs.pr-description-prefix}}"
126136
127137 if ("${{github.event.pull_request.number}}" != "") {
128- body += "本PRをマージすると差分が次のPRに反映されます。\n"
129- body += "* #${{github.event.pull_request.number}}"
130- title += " #${{github.event.pull_request.number}}"
131- }
138+ body += `本PR ( \`${head}\` ) をマージすると差分が次のPRに反映されます。\n`
139+ body += `* #${{github.event.pull_request.number}} ( \`${HEAD_REF}\` )\n`
140+ body += "```mermaid\n"
141+ body += `%%{init: {'gitGraph': {'mainBranchName': '${HEAD_REF}'}}}%%\n`
142+ body += "gitGraph\n"
143+
144+ for (let i = 0; i < 2; i++) {
145+ body += " commit\n"
146+ }
132147
133- let head = "${{steps.set_org_name.outputs.result}}:${{inputs.branch-name-prefix}}"
148+ body += ` branch ${head}\n`
149+ body += ` checkout ${head}\n`
150+ let commit = "${{inputs.pr-title-prefix}}"
134151
135- if (HEAD_REF != "") {
136- head += "-" + HEAD_REF
152+ if (6 < commit.length) {
153+ commit = commit.substring(0, 6) + '......'
154+ }
155+
156+ body += ` commit id: "${commit}"\n`
157+ body += ` checkout ${HEAD_REF}\n`
158+ body += ` merge ${head}\n`
159+ body += "```"
160+ title += " #${{github.event.pull_request.number}}"
137161 }
138162
139163 const pulls_create_params = {
140164 owner: context.repo.owner,
141165 repo: context.repo.repo,
142- head,
166+ head: head_with_repo ,
143167 base: HEAD_REF,
144168 title,
145169 body
@@ -167,18 +191,11 @@ runs:
167191 # 既にformat修正のPRがある状態で、手動でformatを修正した場合、format修正のPRを閉じる
168192 - name : Close PullRequest
169193170- env :
171- HEAD_REF : ${{github.event.pull_request.head.ref}}
172194 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 == ''))
173195 with :
174196 github-token : ${{inputs.github-token}}
175197 script : |
176- let HEAD_REF = process.env["HEAD_REF"]
177-
178- if (HEAD_REF === "" && "${{inputs.base-branch}}" !== "") {
179- HEAD_REF = "${{inputs.base-branch}}"
180- }
181-
198+ const HEAD_REF = "${{steps.get_head_ref.outputs.result}}"
182199 let head_name = "${{inputs.branch-name-prefix}}"
183200
184201 if (HEAD_REF != "") {
0 commit comments