8
8
trigger :
9
9
runs-on : ubuntu-latest
10
10
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
11
16
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
14
22
with :
15
23
script : |
16
24
const user = context.payload.sender.login
@@ -29,24 +37,26 @@ jobs:
29
37
}
30
38
31
39
if (hasTriagePermission) {
32
- console.log('Allowed ')
40
+ console.log('User is allowed. Adding +1 reaction. ')
33
41
await github.rest.reactions.createForIssueComment({
34
42
owner: context.repo.owner,
35
43
repo: context.repo.repo,
36
44
comment_id: context.payload.comment.id,
37
45
content: '+1',
38
46
})
39
47
} else {
40
- console.log('Not allowed')
48
+ console.log('User is not allowed. Adding -1 reaction. ')
41
49
await github.rest.reactions.createForIssueComment({
42
50
owner: context.repo.owner,
43
51
repo: context.repo.repo,
44
52
comment_id: context.payload.comment.id,
45
53
content: '-1',
46
54
})
47
- throw new Error('not allowed ')
55
+ throw new Error('User does not have the necessary permissions. ')
48
56
}
49
- - uses : actions/github-script@v6
57
+
58
+ - name : Get PR Data
59
+ uses : actions/github-script@v7
50
60
id : get-pr-data
51
61
with :
52
62
script : |
@@ -59,21 +69,27 @@ jobs:
59
69
return {
60
70
num: context.issue.number,
61
71
branchName: pr.head.ref,
72
+ commit: pr.head.sha,
62
73
repo: pr.head.repo.full_name
63
74
}
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
66
79
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
71
88
id : trigger
72
89
env :
73
90
COMMENT : ${{ github.event.comment.body }}
74
91
with :
75
92
github-token : ${{ steps.generate-token.outputs.token }}
76
- result-encoding : string
77
93
script : |
78
94
const comment = process.env.COMMENT.trim()
79
95
const prData = ${{ steps.get-pr-data.outputs.result }}
89
105
prNumber: '' + prData.num,
90
106
branchName: prData.branchName,
91
107
repo: prData.repo,
108
+ commit: prData.commit,
92
109
suite: suite === '' ? '-' : suite
93
110
}
94
111
})
0 commit comments