@@ -5,24 +5,27 @@ on: pull_request
55jobs :
66 guardrail :
77 runs-on : ubuntu-latest
8- timeout-minutes : 15
8+
99 steps :
10- - name : Get changed files
11- id : changed-files
12- uses : tj-actions/changed-files@v44
13- with :
14- separator : ' '
15-
1610 - name : Checkout the ${{github.base_ref}} branch
1711 uses : actions/checkout@v4
1812 with :
1913 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+
2124 - name : Use Node.js 20.x
2225 uses : actions/setup-node@v4
2326 with :
2427 node-version : 20.x
25-
28+
2629 - name : Run Coana on the ${{github.base_ref}} branch
2730 run : |
2831 npx @coana-tech/cli run . \
@@ -31,16 +34,20 @@ jobs:
3134 -o /tmp/main-branch \
3235 --changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
3336 --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.
3643 - name : Reset file permissions
3744 run : sudo chown -R $USER:$USER .
38-
45+
3946 - name : Checkout the current branch
4047 uses : actions/checkout@v4
4148 with :
4249 clean : true
43-
50+
4451 - name : Run Coana on the current branch
4552 run : |
4653 npx @coana-tech/cli run . \
@@ -49,12 +56,12 @@ jobs:
4956 -o /tmp/current-branch \
5057 --changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
5158 --lightweight-reachability \
52-
59+
5360 - name : Run Report Comparison
5461 run : |
5562 npx @coana-tech/cli compare-reports \
5663 --api-key ${{ secrets.COANA_API_KEY || 'api-key-unavailable' }} \
5764 /tmp/main-branch/coana-report.json \
5865 /tmp/current-branch/coana-report.json
5966 env :
60- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments