@@ -27,25 +27,22 @@ jobs:
2727 - name : Checkout repository
2828 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929 with :
30- fetch-depth : 0
3130 persist-credentials : false
3231
32+ - name : Setup pnpm
33+ uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
34+
3335 - name : Setup Node.js
3436 uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3537 with :
3638 node-version-file : .node-version
37- cache : ' '
38-
39- - name : Setup pnpm
40- uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
39+ cache : ' pnpm'
4140
4241 - name : Install dependencies
43- shell : bash
4442 run : pnpm install --frozen-lockfile
4543
4644 - name : Check for npm updates
4745 id : check
48- shell : bash
4946 run : |
5047 echo "Checking for npm package updates..."
5148 HAS_UPDATES=false
5956 apply-updates :
6057 name : Apply updates with Claude Code
6158 needs : check-updates
62- if : needs.check-updates.outputs.has-updates == 'true' && github.event. inputs.dry-run != ' true'
59+ if : needs.check-updates.outputs.has-updates == 'true' && inputs.dry-run != true
6360 runs-on : ubuntu-latest
6461 permissions :
6562 contents : write
@@ -71,59 +68,63 @@ jobs:
7168 fetch-depth : 0
7269 persist-credentials : false
7370
71+ - name : Setup pnpm
72+ uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
73+
7474 - name : Setup Node.js
7575 uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
7676 with :
7777 node-version-file : .node-version
78- cache : ' '
79-
80- - name : Setup pnpm
81- uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
78+ cache : ' pnpm'
8279
8380 - name : Install dependencies
84- shell : bash
8581 run : pnpm install --frozen-lockfile
8682
8783 - name : Install Claude Code
88- shell : bash
8984 run : npm install -g @anthropic-ai/claude-code
9085
9186 - name : Create update branch
9287 id : branch
93- shell : bash
88+ env :
89+ GH_TOKEN : ${{ github.token }}
9490 run : |
9591 BRANCH_NAME="weekly-update-$(date +%Y%m%d)"
9692 git config user.name "github-actions[bot]"
9793 git config user.email "github-actions[bot]@users.noreply.github.com"
94+ git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
9895 git checkout -b "$BRANCH_NAME"
9996 echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
10097
10198 - name : Run updating skill with Claude Code
10299 id : claude
103100 timeout-minutes : 30
104- shell : bash
105101 env :
106102 ANTHROPIC_API_KEY : ${{ secrets.ANTHROPIC_API_KEY }}
107103 CI : ' true'
108104 GITHUB_ACTIONS : ' true'
109105 run : |
110106 if [ -z "$ANTHROPIC_API_KEY" ]; then
111- echo "⚠️ ANTHROPIC_API_KEY not set - skipping automated update"
107+ echo "ANTHROPIC_API_KEY not set - skipping automated update"
112108 echo "success=false" >> $GITHUB_OUTPUT
113109 exit 0
114110 fi
115111
116- set -o pipefail
112+ set +e
117113 claude --print --dangerously-skip-permissions \
118114 --model sonnet \
119115 "/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." \
120116 2>&1 | tee claude-output.log
117+ CLAUDE_EXIT=${PIPESTATUS[0]}
118+ set -e
121119
122- echo "success=true" >> $GITHUB_OUTPUT
120+ if [ "$CLAUDE_EXIT" -eq 0 ]; then
121+ echo "success=true" >> $GITHUB_OUTPUT
122+ else
123+ echo "success=false" >> $GITHUB_OUTPUT
124+ fi
123125
124126 - name : Check for changes
125127 id : changes
126- shell : bash
127128 run : |
128129 if [ -n "$(git status --porcelain)" ] || [ "$(git rev-list --count HEAD ^origin/main)" -gt 0 ]; then
129130 echo "has-changes=true" >> $GITHUB_OUTPUT
@@ -133,52 +134,78 @@ jobs:
133134
134135 - name : Push branch
135136 if : steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
136- shell : bash
137137 env :
138- GH_TOKEN : ${{ github.token }}
139138 BRANCH_NAME : ${{ steps.branch.outputs.branch }}
140- run : |
141- git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
142- git push origin "$BRANCH_NAME"
139+ run : git push origin "$BRANCH_NAME"
143140
144141 - name : Create Pull Request
145142 if : steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
146- shell : bash
147143 env :
148144 GH_TOKEN : ${{ github.token }}
149145 BRANCH_NAME : ${{ steps.branch.outputs.branch }}
150146 run : |
151147 COMMITS=$(git log --oneline origin/main..HEAD)
152148 COMMIT_COUNT=$(git rev-list --count origin/main..HEAD)
153149
150+ PR_BODY="## Weekly Dependency Update"$'\n\n'
151+ PR_BODY+="Automated weekly update of npm packages."$'\n\n'
152+ PR_BODY+="---"$'\n\n'
153+ PR_BODY+="### Commits (${COMMIT_COUNT})"$'\n\n'
154+ PR_BODY+="<details>"$'\n'
155+ PR_BODY+="<summary>View commit history</summary>"$'\n\n'
156+ PR_BODY+="\`\`\`"$'\n'
157+ PR_BODY+="${COMMITS}"$'\n'
158+ PR_BODY+="\`\`\`"$'\n\n'
159+ PR_BODY+="</details>"$'\n\n'
160+ PR_BODY+="---"$'\n\n'
161+ PR_BODY+="<sub>Generated by [weekly-update.yml](.github/workflows/weekly-update.yml)</sub>"
162+
154163 gh pr create \
155164 --title "chore(deps): weekly dependency update ($(date +%Y-%m-%d))" \
156- --body "## Weekly Dependency Update
157-
158- Automated weekly update of npm packages.
159-
160- ### Commits (${COMMIT_COUNT})
161-
162- <details>
163- <summary>View commit history</summary>
164-
165- \`\`\`
166- ${COMMITS}
167- \`\`\`
168-
169- </details>
170-
171- ---
172-
173- <sub>Generated by [weekly-update.yml](.github/workflows/weekly-update.yml)</sub>" \
165+ --body "$PR_BODY" \
174166 --draft \
175167 --head "$BRANCH_NAME" \
176168 --base main
177169
170+ - name : Add job summary
171+ if : steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
172+ env :
173+ BRANCH_NAME : ${{ steps.branch.outputs.branch }}
174+ run : |
175+ COMMIT_COUNT=$(git rev-list --count origin/main..HEAD)
176+ echo "## Weekly Update Complete" >> $GITHUB_STEP_SUMMARY
177+ echo "" >> $GITHUB_STEP_SUMMARY
178+ echo "**Branch:** \`${BRANCH_NAME}\`" >> $GITHUB_STEP_SUMMARY
179+ echo "**Commits:** ${COMMIT_COUNT}" >> $GITHUB_STEP_SUMMARY
180+
178181 - name : Upload Claude output
179182 if : always()
180183 uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
181184 with :
182185 name : claude-output-${{ github.run_id }}
183186 path : claude-output.log
184187 retention-days : 7
188+
189+ notify :
190+ name : Notify results
191+ needs : [check-updates, apply-updates]
192+ if : always()
193+ runs-on : ubuntu-latest
194+ permissions :
195+ contents : read
196+ steps :
197+ - name : Report status
198+ env :
199+ HAS_UPDATES : ${{ needs.check-updates.outputs.has-updates }}
200+ DRY_RUN : ${{ inputs.dry-run }}
201+ run : |
202+ if [ "$HAS_UPDATES" = "true" ]; then
203+ if [ "$DRY_RUN" = "true" ]; then
204+ echo "Updates available (dry-run mode - no PR created)"
205+ else
206+ echo "Weekly update workflow completed"
207+ echo "Check the PRs tab for the automated update PR"
208+ fi
209+ else
210+ echo "All dependencies are up to date - no action needed!"
211+ fi
0 commit comments