Skip to content

Commit 385c6df

Browse files
committed
yarn audit workflow yaml
1 parent 51a39d3 commit 385c6df

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

.github/workflows/yarn-audit.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Check smart-contract-tools frontend with yarn audit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- COR-2064/yarn-audit-slack
8+
schedule:
9+
- cron: '0 12 * * *' # run every day at 12
10+
# Allows us to run the workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
env:
14+
NODE_VERSION: 22
15+
16+
jobs:
17+
yarn-audit:
18+
name: Yarn Audit
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
packages:
24+
- front-end-tools
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v6
28+
with:
29+
submodules: 'recursive'
30+
31+
- name: Enable Corepack
32+
run: corepack enable
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v6
36+
with:
37+
node-version: ${{ env.NODE_VERSION }}
38+
cache: yarn
39+
cache-dependency-path: '${{ matrix.packages }}/yarn.lock'
40+
41+
- name: Install dependencies
42+
working-directory: ${{ matrix.packages }}
43+
run: yarn install --immutable
44+
45+
- name: Audit - Critical vulnerabilities
46+
id: audit_critical
47+
working-directory: ${{ matrix.packages }}
48+
run: |
49+
AUDIT_OUTPUT=$(yarn npm audit --all --recursive --severity critical || true)
50+
echo "$AUDIT_OUTPUT"
51+
if echo "$AUDIT_OUTPUT" | grep -Ei "severity: critical" > /dev/null; then
52+
echo "Critical vulnerabilities found!"
53+
exit 1
54+
else
55+
echo "No critical vulnerabilities found."
56+
exit 0
57+
fi
58+
59+
- name: Audit - High vulnerabilities
60+
id: audit_high
61+
working-directory: ${{ matrix.packages }}
62+
run: |
63+
AUDIT_OUTPUT=$(yarn npm audit --all --recursive --severity high || true)
64+
echo "$AUDIT_OUTPUT"
65+
if echo "$AUDIT_OUTPUT" | grep -Ei "severity: high" > /dev/null; then
66+
echo "High vulnerabilities found!"
67+
exit 1
68+
else
69+
echo "No high vulnerabilities found."
70+
exit 0
71+
fi
72+
73+
- name: Report Status to Slack # This step only runs if a previous step failed
74+
if: failure()
75+
uses: rtCamp/action-slack-notify@v2
76+
env:
77+
SLACK_WEBHOOK: ${{ secrets.SECURITY_ADVISORIES_SLACK_WEBHOOK_URL }}
78+
SLACK_COLOR: ${{ job.status }}
79+
SLACK_TITLE: 'Yarn Audit detected vulnerabilities on : ${{ matrix.packages }}'
80+
SLACK_MESSAGE: |
81+
Yarn audit detected Critical or High vulnerabilities for *${{ matrix.packages }}*.
82+
Please check the GitHub Actions logs.
83+
*View Logs:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to open the Summary page>
84+
SLACK_USERNAME: YarnAuditBot

0 commit comments

Comments
 (0)