Skip to content

Commit 8def89f

Browse files
authored
Add coana-guardrail and coana-analysis workflows (#418)
* Add updated coana workflows * trigger CI * fix guardrail for forks
1 parent e085e8a commit 8def89f

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

.github/workflows/coana-analysis.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ name: Coana Vulnerability Analysis
22

33
on:
44
schedule:
5-
# every day at 12 AM
6-
- cron: '0 0 * * *'
5+
- cron: "0 3 * * *" # every day at 3 AM
76
workflow_dispatch:
87
inputs:
98
tags:
10-
description: 'Manually run vulnerability analysis'
9+
description: "Manually run vulnerability analysis"
10+
# Required by the return-dispatch action
11+
distinct_id:
1112

1213
jobs:
1314
coana-vulnerability-analysis:
1415
runs-on: ubuntu-latest
15-
timeout-minutes: 60
1616

1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20+
2021
- name: Run Coana CLI
2122
id: coana-cli
22-
run: |
23-
npx @coana-tech/cli run . \
24-
--api-key ${{ secrets.COANA_API_KEY }} \
25-
--repo-url https://github.com/${{github.repository}}
23+
uses: docker://coana/coana:latest
24+
with:
25+
args: |
26+
coana run . \
27+
--api-key ${{ secrets.COANA_API_KEY }} \
28+
--repo-url https://github.com/${{github.repository}}

.github/workflows/coana-guardrail.yml

+22-15
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,27 @@ on: pull_request
55
jobs:
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

Comments
 (0)