-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (69 loc) · 2.34 KB
/
Copy pathsecurity-audit.yml
File metadata and controls
69 lines (69 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
name: Security Audit
on: # yamllint disable-line rule:truthy
pull_request:
schedule:
- cron: 13 3 * * *
permissions:
contents: read
jobs:
audit:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout code
# yamllint disable-line rule:line-length
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
# yamllint disable-line rule:line-length
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Audit dependencies
run: |
set -o pipefail
uv audit --frozen --preview-features audit-command 2>&1 |
tee audit.log
- name: Report failure in a tracking issue
if: failure() && github.event_name == 'schedule'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
run_url="$run_url/actions/runs/$GITHUB_RUN_ID"
{
echo "Scheduled security audit failed: $run_url"
echo
echo '```'
cat audit.log
echo '```'
echo
echo '<!-- security-audit -->'
} > issue-body.md
issue=$(gh issue list --state open \
--search 'Security audit failing in:title' \
--json number --jq '.[0].number')
if [ -n "$issue" ]; then
gh issue comment "$issue" --body-file issue-body.md
else
gh issue create --title "Security audit failing" \
--body-file issue-body.md
fi
- name: Close the tracking issue
if: success() && github.event_name == 'schedule'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |-
run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
run_url="$run_url/actions/runs/$GITHUB_RUN_ID"
issue=$(gh issue list --state open \
--search 'Security audit failing in:title' \
--json number --jq '.[0].number')
if [ -n "$issue" ]; then
gh issue close "$issue" \
--comment "Scheduled security audit is green again: $run_url"
fi