-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (147 loc) · 5.35 KB
/
weekly-update.yml
File metadata and controls
175 lines (147 loc) · 5.35 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
name: 🔄 Weekly Dependency Update
on:
schedule:
# Run weekly on Monday at 9 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
dry-run:
description: 'Check for updates without creating PR'
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
check-updates:
name: Check for dependency updates
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
has-updates: ${{ steps.check.outputs.has-updates }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: .node-version
cache: ''
- name: Setup pnpm
uses: pnpm/action-setup@b307475762933b98ed359c036b0e51f26b63b74b # v5.0.0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check for npm updates
id: check
run: |
echo "Checking for npm package updates..."
HAS_UPDATES=false
NPM_UPDATES=$(pnpm outdated 2>/dev/null || true)
if [ -n "$NPM_UPDATES" ] && ! echo "$NPM_UPDATES" | grep -q "No outdated"; then
echo "npm packages have updates available"
HAS_UPDATES=true
fi
echo "has-updates=$HAS_UPDATES" >> $GITHUB_OUTPUT
apply-updates:
name: Apply updates with Claude Code
needs: check-updates
if: needs.check-updates.outputs.has-updates == 'true' && inputs.dry-run != true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: .node-version
cache: ''
- name: Setup pnpm
uses: pnpm/action-setup@b307475762933b98ed359c036b0e51f26b63b74b # v5.0.0
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install Claude Code
run: npm install -g @anthropic-ai/claude-code
- name: Create update branch
id: branch
run: |
BRANCH_NAME="weekly-update-$(date +%Y%m%d)"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH_NAME"
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Run updating skill with Claude Code
id: claude
timeout-minutes: 30
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
CI: 'true'
GITHUB_ACTIONS: 'true'
run: |
if [ -z "$ANTHROPIC_API_KEY" ]; then
echo "⚠️ ANTHROPIC_API_KEY not set - skipping automated update"
echo "success=false" >> $GITHUB_OUTPUT
exit 0
fi
claude --print --dangerously-skip-permissions \
--model sonnet \
"/updating - Run the updating skill to update all dependencies. Create atomic commits for each update. You are running in CI mode - skip builds and tests. Do not push or create a PR." \
2>&1 | tee claude-output.log
if [ $? -eq 0 ]; then
echo "success=true" >> $GITHUB_OUTPUT
else
echo "success=false" >> $GITHUB_OUTPUT
fi
- name: Check for changes
id: changes
run: |
if [ -n "$(git status --porcelain)" ] || [ "$(git rev-list --count HEAD ^origin/main)" -gt 0 ]; then
echo "has-changes=true" >> $GITHUB_OUTPUT
else
echo "has-changes=false" >> $GITHUB_OUTPUT
fi
- name: Push branch
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
env:
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
run: git push origin "$BRANCH_NAME"
- name: Create Pull Request
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
run: |
COMMITS=$(git log --oneline origin/main..HEAD)
COMMIT_COUNT=$(git rev-list --count origin/main..HEAD)
gh pr create \
--title "chore(deps): weekly dependency update ($(date +%Y-%m-%d))" \
--body "## Weekly Dependency Update
Automated weekly update of npm packages.
### Commits (${COMMIT_COUNT})
<details>
<summary>View commit history</summary>
\`\`\`
${COMMITS}
\`\`\`
</details>
---
<sub>Generated by [weekly-update.yml](.github/workflows/weekly-update.yml)</sub>" \
--draft \
--head "$BRANCH_NAME" \
--base main
- name: Upload Claude output
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: claude-output-${{ github.run_id }}
path: claude-output.log
retention-days: 7