@@ -5,24 +5,27 @@ on: pull_request
5
5
jobs :
6
6
guardrail :
7
7
runs-on : ubuntu-latest
8
- timeout-minutes : 15
8
+
9
9
steps :
10
- - name : Get changed files
11
- id : changed-files
12
- uses : tj-actions/changed-files@v44
13
- with :
14
- separator : ' '
15
-
16
10
- name : Checkout the ${{github.base_ref}} branch
17
11
uses : actions/checkout@v4
18
12
with :
19
13
ref : ${{github.base_ref}} # checkout the base branch (usually master/main).
20
-
14
+
15
+ - name : Fetch the PR branch
16
+ run : |
17
+ git fetch ${{ github.event.pull_request.head.repo.clone_url }} ${{ github.head_ref }}:${{ github.head_ref }} --depth=1
18
+
19
+ - name : Get list of changed files relative to the main/master branch
20
+ id : changed-files
21
+ run : |
22
+ echo "all_changed_files=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | tr '\n' ' ')" >> $GITHUB_OUTPUT
23
+
21
24
- name : Use Node.js 20.x
22
25
uses : actions/setup-node@v4
23
26
with :
24
27
node-version : 20.x
25
-
28
+
26
29
- name : Run Coana on the ${{github.base_ref}} branch
27
30
run : |
28
31
npx @coana-tech/cli run . \
@@ -31,16 +34,20 @@ jobs:
31
34
-o /tmp/main-branch \
32
35
--changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
33
36
--lightweight-reachability \
34
-
35
- # Reset file permissions changed by Coana CLI.
37
+
38
+ # Reset file permissions.
39
+ # This is necessary because the Coana CLI may add
40
+ # new files with root ownership since it's using docker.
41
+ # These files will not be deleted by the clean step in checkout
42
+ # if the permissions are not reset.
36
43
- name : Reset file permissions
37
44
run : sudo chown -R $USER:$USER .
38
-
45
+
39
46
- name : Checkout the current branch
40
47
uses : actions/checkout@v4
41
48
with :
42
49
clean : true
43
-
50
+
44
51
- name : Run Coana on the current branch
45
52
run : |
46
53
npx @coana-tech/cli run . \
@@ -49,12 +56,12 @@ jobs:
49
56
-o /tmp/current-branch \
50
57
--changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
51
58
--lightweight-reachability \
52
-
59
+
53
60
- name : Run Report Comparison
54
61
run : |
55
62
npx @coana-tech/cli compare-reports \
56
63
--api-key ${{ secrets.COANA_API_KEY || 'api-key-unavailable' }} \
57
64
/tmp/main-branch/coana-report.json \
58
65
/tmp/current-branch/coana-report.json
59
66
env :
60
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments