Skip to content

Commit

Permalink
処理内容を説明するコメント追加 (#1687)
Browse files Browse the repository at this point in the history
* 処理内容を説明するコメント追加

* format修正のPR -> 修正PR
  • Loading branch information
massongit authored Sep 12, 2024
1 parent 73e6a8b commit 7cc8ab1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ runs:
script: |
const script = require('${{ github.action_path }}/scripts/action/get_pull_requests.js')
return await script({github, context})
# pushしたブランチでPRを作る
# pushしたブランチで修正PRを作る
- name: Create PullRequest
uses: actions/[email protected]
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')
Expand All @@ -79,6 +79,7 @@ runs:
script: |
const script = require('${{ github.action_path }}/scripts/action/create_pull_request.js')
return await script({github, context})
# 元のPRを出したユーザーを修正PRにアサインする
- name: Assign a user
uses: actions/[email protected]
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]'
Expand All @@ -89,7 +90,7 @@ runs:
script: |
const script = require('${{ github.action_path }}/scripts/action/assign_a_user.js')
await script({github, context})
# 既にformat修正のPRがある状態で、手動でformatを修正した場合、format修正のPRを閉じる
# 既に修正PRがある状態で、手動でformatを修正した場合、修正PRを閉じる
- name: Close PullRequest
uses: actions/[email protected]
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 == '')
Expand All @@ -100,6 +101,7 @@ runs:
script: |
const script = require('${{ github.action_path }}/scripts/action/close_pull_request.js')
await script({github, context})
# exit-failureがtrueで差分がある場合は異常終了する
- name: Exit
if: (github.event_name != 'pull_request' || github.event.action != 'closed') && steps.diff.outputs.result != '' && inputs.exit-failure == 'true'
run: exit 1
Expand Down
5 changes: 5 additions & 0 deletions scripts/action/close_pull_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = async ({ github, context }) => {
owner: context.repo.owner,
repo: context.repo.repo,
};

// 修正PRの情報を取得する
const pullsListParams = {
head: context.repo.owner + ":" + headName,
state: "open",
Expand All @@ -19,13 +21,16 @@ module.exports = async ({ github, context }) => {
const pulls = await github.paginate(github.rest.pulls.list, pullsListParams);

for (const pull of pulls) {
// 修正PRをcloseする (修正PRのstateをclosedに更新する)
const pullsUpdateParams = {
pull_number: pull.number,
state: "closed",
...commonParams,
};
console.log("call pulls.update:", pullsUpdateParams);
await github.rest.pulls.update(pullsUpdateParams);

// 修正PRのブランチを削除する
const gitDeleteRefParams = {
ref: "heads/" + headName,
...commonParams,
Expand Down

0 comments on commit 7cc8ab1

Please sign in to comment.