Skip to content

Commit 270a36d

Browse files
authored
情報をスクリプト内の変数から取得する (#1488)
* Organization名取得をスクリプト内の変数を参照する形で行う * 変数取得をスクリプト内の変数を参照する形で行う
1 parent 1143de2 commit 270a36d

7 files changed

Lines changed: 7 additions & 27 deletions

File tree

action.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,18 @@ runs:
4646
- name: Push
4747
env:
4848
PR_TITLE_PREFIX: ${{inputs.pr-title-prefix}}
49-
AUTHOR: ${{github.actor}}
5049
TOKEN: ${{inputs.github-token}}
51-
REPOSITORY: ${{github.repository}}
5250
BRANCH_NAME_PREFIX: ${{inputs.branch-name-prefix}}
5351
NO_VERIFY: ${{inputs.no-verify}}
5452
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')
5553
working-directory: ${{inputs.working-directory}}
5654
run: ${{ github.action_path }}/scripts/action/push.sh
5755
shell: bash
58-
- name: Set org name
59-
uses: actions/github-script@v7.0.1
60-
if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch'
61-
id: set_org_name
62-
with:
63-
github-token: ${{inputs.github-token}}
64-
result-encoding: string
65-
script: |
66-
const script = require('${{ github.action_path }}/scripts/action/set_org_name.js')
67-
return script()
6856
- name: Get PullRequests
6957
uses: actions/github-script@v7.0.1
7058
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')
7159
id: get_pull_requests
7260
env:
73-
ORG_NAME: ${{steps.set_org_name.outputs.result}}
7461
BRANCH_NAME_PREFIX: ${{inputs.branch-name-prefix}}
7562
with:
7663
github-token: ${{inputs.github-token}}
@@ -83,9 +70,7 @@ runs:
8370
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')
8471
id: create_pull_request
8572
env:
86-
ORG_NAME: ${{steps.set_org_name.outputs.result}}
8773
PR_DESCRIPTION_PREFIX: ${{inputs.pr-description-prefix}}
88-
PR_NUMBER: ${{github.event.pull_request.number}}
8974
PR_TITLE_PREFIX: ${{inputs.pr-title-prefix}}
9075
BRANCH_NAME_PREFIX: ${{inputs.branch-name-prefix}}
9176
with:
@@ -98,7 +83,6 @@ runs:
9883
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]'
9984
env:
10085
PR_NUMBER: ${{steps.create_pull_request.outputs.result}}
101-
ASSIGN_USER: ${{github.event.pull_request.user.login}}
10286
with:
10387
github-token: ${{inputs.github-token}}
10488
script: |
@@ -109,7 +93,6 @@ runs:
10993
uses: actions/github-script@v7.0.1
11094
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 == '')
11195
env:
112-
ORG_NAME: ${{steps.set_org_name.outputs.result}}
11396
BRANCH_NAME_PREFIX: ${{inputs.branch-name-prefix}}
11497
with:
11598
github-token: ${{inputs.github-token}}

scripts/action/assign_a_user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = async ({ github, context }) => {
33
owner: context.repo.owner,
44
repo: context.repo.repo,
55
issue_number: process.env.PR_NUMBER,
6-
assignees: [process.env.ASSIGN_USER]
6+
assignees: [context.actor]
77
}
88
console.log('call issues.addAssignees:')
99
console.log(issuesAddAssigneesParams)

scripts/action/close_pull_request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = async ({ github, context }) => {
1111
repo: context.repo.repo
1212
}
1313
const pullsListParams = {
14-
head: process.env.ORG_NAME + ':' + headName,
14+
head: context.repo.owner + ':' + headName,
1515
state: 'open',
1616
...commonParams
1717
}

scripts/action/create_pull_request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = async ({ github, context }) => {
22
const HEAD_REF = process.env.HEAD_REF
33
const escapedHeadRef = HEAD_REF.replaceAll('#', '')
4-
const PR_NUMBER = process.env.PR_NUMBER
4+
const PR_NUMBER = context.payload.number
55
const PR_TITLE_PREFIX = process.env.PR_TITLE_PREFIX
66
let head = process.env.BRANCH_NAME_PREFIX
77

@@ -10,7 +10,7 @@ module.exports = async ({ github, context }) => {
1010
}
1111

1212
const escapedHead = head.replaceAll('#', '')
13-
const headWithRepo = process.env.ORG_NAME + ':' + head
13+
const headWithRepo = context.repo.owner + ':' + head
1414
let title = PR_TITLE_PREFIX
1515
let body = process.env.PR_DESCRIPTION_PREFIX
1616

scripts/action/get_pull_requests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = async ({ github, context }) => {
22
const HEAD_REF = process.env.HEAD_REF
3-
let head = process.env.ORG_NAME + ':' + process.env.BRANCH_NAME_PREFIX
3+
let head = context.repo.owner + ':' + process.env.BRANCH_NAME_PREFIX
44

55
if (HEAD_REF !== '') {
66
head += '-' + HEAD_REF

scripts/action/push.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ fi
1212
GIT_COMMIT_COMMAND="$GIT_COMMIT_COMMAND -m \"${PR_TITLE_PREFIX}\""
1313
eval "$GIT_COMMIT_COMMAND"
1414
REPO_URL="https://"
15-
REPO_URL+="${AUTHOR}:${TOKEN}@github.com/"
16-
REPO_URL+="${REPOSITORY}.git"
15+
REPO_URL+="${GITHUB_ACTOR}:${TOKEN}@github.com/"
16+
REPO_URL+="${GITHUB_REPOSITORY}.git"
1717
GITHUB_HEAD="HEAD:refs/heads/${BRANCH_NAME_PREFIX}-${HEAD_REF}"
1818
GIT_PUSH_COMMAND="git push"
1919

scripts/action/set_org_name.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)