-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (168 loc) · 6.62 KB
/
dependabot-lockfile.yml
File metadata and controls
195 lines (168 loc) · 6.62 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Fix Dependabot PRs
on:
pull_request_target:
branches: [main]
permissions:
actions: read
contents: write
pull-requests: write
jobs:
fix-dependabot:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check if Dependabot PR
id: guard
env:
GH_TOKEN: ${{ github.token }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
if [[ "$PR_AUTHOR" != "dependabot[bot]" ]]; then
echo "Not a Dependabot PR (author: $PR_AUTHOR), nothing to do."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Prevent infinite loops: count how many times this workflow has already
# run successfully on this branch (max 2 attempts: initial + one retry)
RUN_COUNT=$(gh api "repos/${{ github.repository }}/actions/workflows/dependabot-lockfile.yml/runs?branch=$HEAD_REF&status=success" --jq '.total_count')
if [[ "$RUN_COUNT" -ge 2 ]]; then
echo "Already ran $RUN_COUNT times on this branch, skipping to prevent loop."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "skip=false" >> "$GITHUB_OUTPUT"
- name: Generate App Token
if: steps.guard.outputs.skip != 'true'
id: generate-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Checkout Dependabot branch
if: steps.guard.outputs.skip != 'true'
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.generate-token.outputs.token }}
- name: Set up pnpm
if: steps.guard.outputs.skip != 'true'
uses: pnpm/action-setup@v5
with:
version: 10
- name: Set up Node.js
if: steps.guard.outputs.skip != 'true'
uses: actions/setup-node@v6
with:
node-version: "22.x"
- name: Configure git identity
if: steps.guard.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Regenerate lockfile
if: steps.guard.outputs.skip != 'true'
run: pnpm install --no-frozen-lockfile --ignore-scripts
- name: Commit lockfile changes
if: steps.guard.outputs.skip != 'true'
id: lockfile
run: |
if git diff --quiet pnpm-lock.yaml; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
git add pnpm-lock.yaml
git commit -m "fix(deps): regenerate pnpm-lock.yaml"
git push
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Try building
if: steps.guard.outputs.skip != 'true'
id: build
continue-on-error: true
run: |
set -o pipefail
pnpm install --frozen-lockfile
pnpm run build 2>&1 | tee /tmp/build-output.txt
- name: Try linting
if: steps.guard.outputs.skip != 'true' && steps.build.outcome == 'success'
id: lint
continue-on-error: true
run: |
set -o pipefail
pnpm exec eslint . 2>&1 | tee /tmp/lint-output.txt
- name: Try testing
if: steps.guard.outputs.skip != 'true' && steps.build.outcome == 'success'
id: test
continue-on-error: true
run: |
set -o pipefail
failed=0
pnpm test:unit 2>&1 | tee /tmp/test-output.txt || failed=1
pnpm --filter @ably/react-web-cli test 2>&1 | tee -a /tmp/test-output.txt || failed=1
exit $failed
- name: Check if fixes needed
if: steps.guard.outputs.skip != 'true'
id: needs-fix
run: |
if [[ "${{ steps.build.outcome }}" == "failure" || "${{ steps.lint.outcome }}" == "failure" || "${{ steps.test.outcome }}" == "failure" ]]; then
echo "needed=true" >> "$GITHUB_OUTPUT"
else
echo "needed=false" >> "$GITHUB_OUTPUT"
fi
- name: Capture error output
if: steps.needs-fix.outputs.needed == 'true'
id: errors
run: |
{
echo "build_output<<ENDOFOUTPUT"
if [ -f /tmp/build-output.txt ]; then
tail -n 200 /tmp/build-output.txt
else
echo "No build output captured"
fi
echo "ENDOFOUTPUT"
echo "lint_output<<ENDOFOUTPUT"
if [ -f /tmp/lint-output.txt ]; then
tail -n 200 /tmp/lint-output.txt
else
echo "Lint was not run"
fi
echo "ENDOFOUTPUT"
echo "test_output<<ENDOFOUTPUT"
if [ -f /tmp/test-output.txt ]; then
tail -n 200 /tmp/test-output.txt
else
echo "Tests were not run"
fi
echo "ENDOFOUTPUT"
} >> "$GITHUB_OUTPUT"
- name: Fix issues with Claude
if: steps.needs-fix.outputs.needed == 'true'
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ steps.generate-token.outputs.token }}
direct_prompt: |
This is a Dependabot PR that bumps dependencies. The lockfile has been
regenerated but the build, lint, or tests are failing.
Read .claude/CLAUDE.md for project context.
## Errors
Build output (if failed):
${{ steps.errors.outputs.build_output }}
Lint output (if failed):
${{ steps.errors.outputs.lint_output }}
Test output (if failed):
${{ steps.errors.outputs.test_output }}
## Instructions
1. Diagnose why the build/lint/tests fail after the dependency bump
2. Make the MINIMUM changes needed to fix it — do not refactor unrelated code
3. Run `pnpm run build`, `pnpm exec eslint .`, `pnpm test:unit`, and `pnpm --filter @ably/react-web-cli test` to verify your fixes
4. Commit your changes with a descriptive message
5. Push to the current branch
If the fix requires significant code changes beyond simple type/import
adjustments, leave a PR comment explaining what's needed instead of
attempting a risky fix.
claude_args: |
--max-turns 30
--model claude-sonnet-4-6
--allowedTools "Bash,Read,Write,Edit,Glob,Grep"