Skip to content

Commit 50e557c

Browse files
authored
Merge pull request #467 from openwallet-foundation-labs/feat/dependabot-automation
feat: add Dependabot automation workflows
2 parents 95764aa + 48bb9e3 commit 50e557c

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Check Stale Overrides
2+
3+
permissions:
4+
contents: read
5+
issues: write
6+
7+
on:
8+
schedule:
9+
- cron: '0 6 * * 1' # Weekly on Monday 6 AM UTC
10+
workflow_dispatch: # Manual trigger
11+
12+
jobs:
13+
check-overrides:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: pnpm/action-setup@v4
19+
with:
20+
version: 10
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: '22'
25+
cache: 'pnpm'
26+
27+
- name: Install dependencies
28+
run: pnpm install --frozen-lockfile
29+
30+
- name: Check for stale overrides
31+
id: check
32+
run: |
33+
# Extract overrides from package.json
34+
OVERRIDES=$(node -e "
35+
const pkg = require('./package.json');
36+
const overrides = pkg.pnpm?.overrides || {};
37+
Object.entries(overrides).forEach(([name, version]) => {
38+
console.log(name + '@' + version);
39+
});
40+
")
41+
42+
if [ -z "$OVERRIDES" ]; then
43+
echo "No pnpm overrides configured"
44+
echo "has_overrides=false" >> $GITHUB_OUTPUT
45+
exit 0
46+
fi
47+
48+
echo "has_overrides=true" >> $GITHUB_OUTPUT
49+
echo "## Current pnpm.overrides" >> $GITHUB_STEP_SUMMARY
50+
echo "" >> $GITHUB_STEP_SUMMARY
51+
echo "The following overrides are pinned in package.json:" >> $GITHUB_STEP_SUMMARY
52+
echo "" >> $GITHUB_STEP_SUMMARY
53+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
54+
echo "$OVERRIDES" >> $GITHUB_STEP_SUMMARY
55+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
56+
echo "" >> $GITHUB_STEP_SUMMARY
57+
echo "### Action Required" >> $GITHUB_STEP_SUMMARY
58+
echo "Check if parent packages have been updated to use fixed versions of these dependencies." >> $GITHUB_STEP_SUMMARY
59+
echo "If so, remove the override from \`package.json\` and run \`pnpm install\`." >> $GITHUB_STEP_SUMMARY
60+
61+
- name: Create issue if overrides exist
62+
if: steps.check.outputs.has_overrides == 'true'
63+
uses: actions/github-script@v7
64+
with:
65+
script: |
66+
const pkg = require('./package.json');
67+
const overrides = pkg.pnpm?.overrides || {};
68+
69+
if (Object.keys(overrides).length === 0) return;
70+
71+
// Check if issue already exists
72+
const issues = await github.rest.issues.listForRepo({
73+
owner: context.repo.owner,
74+
repo: context.repo.repo,
75+
labels: 'stale-overrides',
76+
state: 'open'
77+
});
78+
79+
if (issues.data.length > 0) {
80+
console.log('Issue already exists, skipping');
81+
return;
82+
}
83+
84+
const overrideList = Object.entries(overrides)
85+
.map(([name, version]) => `- \`${name}\`: ${version}`)
86+
.join('\n');
87+
88+
await github.rest.issues.create({
89+
owner: context.repo.owner,
90+
repo: context.repo.repo,
91+
title: 'Review pnpm.overrides for stale security fixes',
92+
labels: ['stale-overrides', 'dependencies'],
93+
body: `## Stale Override Check
94+
95+
The following subdependency overrides are configured in \`package.json\`:
96+
97+
${overrideList}
98+
99+
### Action Required
100+
101+
1. Check if the parent packages have been updated to include fixed versions
102+
2. Remove any overrides that are no longer needed:
103+
- Edit \`package.json\` and remove the override from \`pnpm.overrides\`
104+
- Run \`pnpm install\` to update the lockfile
105+
- Verify the vulnerability is resolved with \`pnpm audit\`
106+
107+
### Why This Matters
108+
109+
Overrides pin subdependencies to specific versions. Once upstream packages are fixed, these overrides become stale and may:
110+
- Prevent you from getting newer fixes
111+
- Create version conflicts
112+
- Make \`pnpm audit\` report false negatives
113+
114+
---
115+
*This issue was automatically created by the stale-overrides workflow.*`
116+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Dependabot Auto-Approve
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
auto-approve:
13+
runs-on: ubuntu-latest
14+
if: github.actor == 'dependabot[bot]'
15+
steps:
16+
- name: Fetch Dependabot metadata
17+
id: metadata
18+
uses: dependabot/fetch-metadata@v2
19+
with:
20+
github-token: "${{ secrets.GITHUB_TOKEN }}"
21+
22+
# Auto-approve patch updates to reduce friction
23+
# Still requires CI to pass and manual merge for production dependencies
24+
- name: Auto-approve patch updates
25+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
26+
run: gh pr review --approve "$PR_URL"
27+
env:
28+
PR_URL: ${{ github.event.pull_request.html_url }}
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
# Only auto-merge for DEVELOPMENT dependencies (test tools, linters, etc.)
32+
# Production/runtime dependencies still require manual merge after CI passes
33+
- name: Enable auto-merge for dev dependency patches only
34+
if: |
35+
steps.metadata.outputs.update-type == 'version-update:semver-patch' &&
36+
steps.metadata.outputs.dependency-type == 'direct:development'
37+
run: gh pr merge --auto --squash "$PR_URL"
38+
env:
39+
PR_URL: ${{ github.event.pull_request.html_url }}
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)