1
- name : Build & test # on both PRs and push to develop/main
1
+ name : Build & test # on PRs (including forks) and push to develop/main
2
2
3
3
on :
4
- pull_request :
5
- branches : [develop ]
4
+ pull_request_target :
5
+ types : [opened, synchronize ]
6
6
push :
7
7
branches : [develop]
8
8
9
9
jobs :
10
10
build-and-test :
11
- name : Build & test
12
11
runs-on : ubuntu-latest
13
12
steps :
14
- - uses : actions/checkout@v4
13
+ # Get user permission of workflow triggering actor, return true or false
14
+ - name : Get Workflow Actor Permission
15
+ id : checkAccess
16
+ # Action used: https://github.com/actions-cool/check-user-permission
17
+ uses : actions-cool/check-user-permission@v2
18
+ with :
19
+ require : write
20
+ username : ${{ github.triggering_actor }}
21
+ env :
22
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23
+ # Check user permission from previous step, exit if false
24
+ - name : Check Workflow Actor Permission
25
+ if : steps.checkAccess.outputs.require-result == 'false'
26
+ run : |
27
+ echo "${{ github.triggering_actor }} does not have permissions to run workflows on this repo."
28
+ echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
29
+ echo "Job originally triggered by ${{ github.actor }}"
30
+ exit 1
31
+ # Checkout PR code
32
+ - name : Checkout code
33
+ uses : actions/checkout@v4
34
+ with :
35
+ # This is dangerous without the first access check
36
+ ref : ${{ github.event.pull_request.head.sha }}
15
37
- name : Get yarn cache directory path
16
38
id : yarn-cache-dir-path
17
39
run : echo "::set-output name=dir::$(yarn cache dir)"
@@ -26,14 +48,11 @@ jobs:
26
48
- name : Use NodeJs
27
49
uses : actions/setup-node@v3
28
50
with :
29
- node-version : ' 20.x'
30
-
51
+ node-version : " 20.x"
31
52
- name : Install dependencies
32
53
run : yarn install --frozen-lockfile --non-interactive
33
-
34
54
- name : Run linting
35
55
run : yarn lint
36
-
37
56
- name : Build app
38
57
run : yarn build
39
58
env :
0 commit comments