File tree Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Original file line number Diff line number Diff line change 7
7
- cron : ' 0 0 * * *'
8
8
9
9
jobs :
10
- remove_label :
10
+ access_check :
11
11
runs-on : ubuntu-latest
12
+ name : Access check
12
13
steps :
13
- - name : Remove safe-to-test label
14
+ - name : Ensure pull-request is safe to run
14
15
uses : actions/github-script@v5
15
16
with :
16
17
github-token : ${{secrets.GITHUB_TOKEN}}
17
18
script : |
18
19
const issue_number = context.issue.number;
19
20
const repository = context.repo.repo;
20
21
const owner = context.repo.owner;
22
+
21
23
const response = await github.rest.issues.listLabelsOnIssue({
22
24
owner,
23
25
repo: repository,
24
26
issue_number
25
27
});
26
28
const labels = response.data.map(label => label.name);
27
- if (labels.includes('safe-to-test')) {
28
- await github.rest.issues.removeLabel({
29
- owner,
30
- repo: repository,
31
- issue_number,
32
- name: 'safe-to-test'
33
- });
29
+ let hasLabel = labels.includes('safe-to-test')
30
+
31
+ if (context.eventName === 'synchronize' && hasLabel) {
32
+ hasLabel = false
33
+ await github.rest.issues.removeLabel({
34
+ owner,
35
+ repo: repository,
36
+ issue_number,
37
+ name: 'safe-to-test'
38
+ });
39
+ }
40
+
41
+ if (!hasLabel) {
42
+ throw "Action was not authorized. Exiting now."
34
43
}
35
-
36
- access_check :
37
- runs-on : ubuntu-latest
38
- needs : remove_label
39
- steps :
40
- - name : Check user permissions
41
- if : ${{ ! contains(github.event.pull_request.labels.*.name, 'safe-to-test') }}
42
- run : |
43
- echo "Action was not authorized. Exiting now."
44
- exit 1
45
44
46
45
php-tests :
47
46
runs-on : ubuntu-latest
You can’t perform that action at this time.
0 commit comments