Skip to content

Commit 96c1f7c

Browse files
authored
Merge pull request #53 from workos/nicknisi/coana-workflows-revised
Add coana-guardrail and coana-analysis workflows
2 parents 23b2cde + 85c865f commit 96c1f7c

2 files changed

Lines changed: 78 additions & 8 deletions

File tree

.github/workflows/coana-analysis.yml

Lines changed: 11 additions & 8 deletions
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}}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Coana Guardrail
2+
3+
on: pull_request
4+
5+
jobs:
6+
guardrail:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout the ${{github.base_ref}} branch
11+
uses: actions/checkout@v4
12+
with:
13+
ref: ${{github.base_ref}} # checkout the base branch (usually master/main).
14+
15+
- name: Fetch the PR branch
16+
run: |
17+
git fetch origin ${{ 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+
24+
- name: Use Node.js 20.x
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20.x
28+
29+
- name: Run Coana on the ${{github.base_ref}} branch
30+
run: |
31+
npx @coana-tech/cli run . \
32+
--guardrail-mode \
33+
--api-key ${{ secrets.COANA_API_KEY || 'api-key-unavailable' }} \
34+
-o /tmp/main-branch \
35+
--changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
36+
--lightweight-reachability \
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.
43+
- name: Reset file permissions
44+
run: sudo chown -R $USER:$USER .
45+
46+
- name: Checkout the current branch
47+
uses: actions/checkout@v4
48+
with:
49+
clean: true
50+
51+
- name: Run Coana on the current branch
52+
run: |
53+
npx @coana-tech/cli run . \
54+
--guardrail-mode \
55+
--api-key ${{ secrets.COANA_API_KEY || 'api-key-unavailable' }} \
56+
-o /tmp/current-branch \
57+
--changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
58+
--lightweight-reachability \
59+
60+
- name: Run Report Comparison
61+
run: |
62+
npx @coana-tech/cli compare-reports \
63+
--api-key ${{ secrets.COANA_API_KEY || 'api-key-unavailable' }} \
64+
/tmp/main-branch/coana-report.json \
65+
/tmp/current-branch/coana-report.json
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)