8000 chore: update svelte-ecosystem-ci trigger · sveltejs/svelte@e54b061 · GitHub
[go: up one dir, main page]

Skip to content

Commit e54b061

Browse files
committed
chore: update svelte-ecosystem-ci trigger
1 parent 1404623 commit e54b061

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

.github/workflows/ecosystem-ci-trigger.yml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ jobs:
88
trigger:
99
runs-on: ubuntu-latest
1010
if: github.repository == 'sveltejs/svelte' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/ecosystem-ci run')
11+
permissions:
12+
issues: write # to add / delete reactions
13+
pull-requests: read # to read PR data
14+
actions: read # to check workflow status
15+
contents: read # to clone the repo
1116
steps:
12-
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
13-
- uses: actions/github-script@v6
17+
- name: monitor action permissions
18+
uses: GitHubSecurityLab/actions-permissions/monitor@v1
19+
- name: check user authorization # user needs triage permission
20+
uses: actions/github-script@v7
21+
id: check-permissions
1422
with:
1523
script: |
1624
const user = context.payload.sender.login
@@ -29,24 +37,26 @@ jobs:
2937
}
3038
3139
if (hasTriagePermission) {
32-
console.log('Allowed')
40+
console.log('User is allowed. Adding +1 reaction.')
3341
await github.rest.reactions.createForIssueComment({
3442
owner: context.repo.owner,
3543
repo: context.repo.repo,
3644
comment_id: context.payload.comment.id,
3745
content: '+1',
3846
})
3947
} else {
40-
console.log('Not allowed')
48+
console.log('User is not allowed. Adding -1 reaction.')
4149
await github.rest.reactions.createForIssueComment({
4250
owner: context.repo.owner,
4351
repo: context.repo.repo,
4452
comment_id: context.payload.comment.id,
4553
content: '-1',
4654
})
47-
throw new Error('not allowed')
55+
throw new Error('User does not have the necessary permissions.')
4856
}
49-
- uses: actions/github-script@v6
57+
58+
- name: Get PR Data
59+
uses: actions/github-script@v7
5060
id: get-pr-data
5161
with:
5262
script: |
@@ -59,21 +69,27 @@ jobs:
5969
return {
6070
num: context.issue.number,
6171
branchName: pr.head.ref,
72+
commit: pr.head.sha,
6273
repo: pr.head.repo.full_name
6374
}
64-
- id: generate-token
65-
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 #keep pinned for security reasons, currently 1.8.0
75+
76+
- name: Generate Token
77+
id: generate-token
78+
uses: actions/create-github-app-token@v2
6679
with:
67-
app_id: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_ID }}
68-
private_key: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_PRIVATE_KEY }}
69-
repository: '${{ github.repository_owner }}/svelte-ecosystem-ci'
70-
- uses: actions/github-script@v6
80+
app-id: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_ID }}
81+
private-key: ${{ secrets.ECOSYSTEM_CI_GITHUB_APP_PRIVATE_KEY }}
82+
repositories: |
83+
svelte
84+
svelte-ecosystem-ci
85+
86+
- name: Trigger Downstream Workflow
87+
uses: actions/github-script@v7
7188
id: trigger
7289
env:
7390
COMMENT: ${{ github.event.comment.body }}
7491
with:
7592
github-token: ${{ steps.generate-token.outputs.token }}
76-
result-encoding: string
7793
script: |
7894
const comment = process.env.COMMENT.trim()
7995
const prData = ${{ steps.get-pr-data.outputs.result }}
@@ -89,6 +105,7 @@ jobs:
89105
prNumber: '' + prData.num,
90106
branchName: prData.branchName,
91107
repo: prData.repo,
108+
commit: prData.commit,
92109
suite: suite === '' ? '-' : suite
93110
}
94111
})

0 commit comments

Comments
 (0)
0