File tree Expand file tree Collapse file tree 2 files changed +80
-0
lines changed
Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Audit fix Auto-merge
2+
3+ on :
4+ pull_request :
5+ branches : ["main"]
6+
7+ permissions :
8+ contents : write
9+ pull-requests : write
10+
11+ jobs :
12+ auto-merge :
13+ name : Auto-merge audit fix pull requests
14+ runs-on : ubuntu-latest
15+ if : " contains(github.event.pull_request.labels.*.name, 'audit: fix')"
16+ steps :
17+ - name : Approve
18+ run : gh pr review "$PR_URL" --approve --comment --body "Auto-approve audit fix pull requests"
19+ env :
20+ PR_URL : ${{ github.event.pull_request.html_url }}
21+ GH_TOKEN : ${{ secrets.LOCALSTACK_BOT_TOKEN }}
22+ - name : Enable auto-merge
23+ run : gh pr merge "$PR_URL" --auto --squash
24+ env :
25+ PR_URL : ${{ github.event.pull_request.html_url }}
26+ GH_TOKEN : ${{ secrets.LOCALSTACK_BOT_TOKEN }}
Original file line number Diff line number Diff line change 1+ name : Audit fix
2+
3+ on :
4+ schedule :
5+ - cron : ' 0 9 * * *'
6+ workflow_dispatch :
7+
8+ permissions :
9+ contents : write
10+ pull-requests : write
11+
12+ jobs :
13+ audit-fix :
14+ name : Run npm audit fix and create pull request
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Checkout
18+ uses : actions/checkout@v5
19+
20+ - name : Setup Node
21+ uses : actions/setup-node@v4
22+ with :
23+ cache : npm
24+
25+ - name : Install dependencies
26+ run : npm ci
27+
28+ - name : Run npm audit fix
29+ run : npm audit fix --force
30+
31+ - name : Create pull request
32+ env :
33+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
34+ GH_REPO : ${{ github.repository }}
35+ run : |
36+ if git diff --quiet; then
37+ echo "No changes after npm audit fix, skipping PR creation"
38+ exit 0
39+ fi
40+
41+ BRANCH="npm-audit-fix-$(date +%Y%m%d)"
42+ git config user.name "github-actions[bot]"
43+ git config user.email "github-actions[bot]@users.noreply.github.com"
44+ git checkout -b "$BRANCH"
45+ git add package.json package-lock.json
46+ git commit -m "chore(deps): npm audit fix"
47+ git push origin "$BRANCH"
48+
49+ gh pr create \
50+ --title "chore(deps): npm audit fix" \
51+ --body "Automated security fixes via \`npm audit fix --force\`." \
52+ --label "audit: fix" \
53+ --base main \
54+ --head "$BRANCH"
You can’t perform that action at this time.
0 commit comments