-
-
Notifications
You must be signed in to change notification settings - Fork 3
73 lines (59 loc) · 2.16 KB
/
security-check.yml
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
70
71
72
73
name: Security Check
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
jobs:
security-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Security Check
uses: symfonycorp/security-checker-action@v5
id: security-check
- name: Create or Update Security Issue
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const securityCheckOutput = fs.readFileSync('${{ steps.security-check.outputs.logfile }}', 'utf8');
const issueBody = `
# Security Vulnerabilities Detected
The security check has detected vulnerabilities in the project dependencies.
## Details:
\`\`\`
${securityCheckOutput}
\`\`\`
Please review these vulnerabilities and update the affected dependencies if possible.
_This issue was automatically created by the Security Check GitHub Action._
`;
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: ['security']
});
const existingIssue = issues.data.find(issue => issue.title.includes('Security Vulnerabilities Detected'));
if (existingIssue) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: issueBody
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Security Vulnerabilities Detected',
body: issueBody,
labels: ['security']
});
}