@@ -29,14 +29,14 @@ jobs:
2929 with :
3030 persist-credentials : false
3131
32+ - name : Setup pnpm
33+ uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
34+
3235 - name : Setup Node.js
3336 uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3437 with :
3538 node-version-file : .node-version
36- cache : ' '
37-
38- - name : Setup pnpm
39- uses : pnpm/action-setup@58e6119fe4f3092a76a7771efb55e04d25b6b26f # v5
39+ cache : ' pnpm'
4040
4141 - name : Install dependencies
4242 run : pnpm install --frozen-lockfile
5656 apply-updates :
5757 name : Apply updates with Claude Code
5858 needs : check-updates
59- 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
6060 runs-on : ubuntu-latest
6161 permissions :
6262 contents : write
@@ -68,14 +68,14 @@ jobs:
6868 fetch-depth : 0
6969 persist-credentials : false
7070
71+ - name : Setup pnpm
72+ uses : pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
73+
7174 - name : Setup Node.js
7275 uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
7376 with :
7477 node-version-file : .node-version
75- cache : ' '
76-
77- - name : Setup pnpm
78- uses : pnpm/action-setup@58e6119fe4f3092a76a7771efb55e04d25b6b26f # v5
78+ cache : ' pnpm'
7979
8080 - name : Install dependencies
8181 run : pnpm install --frozen-lockfile
@@ -85,10 +85,13 @@ jobs:
8585
8686 - name : Create update branch
8787 id : branch
88+ env :
89+ GH_TOKEN : ${{ github.token }}
8890 run : |
8991 BRANCH_NAME="weekly-update-$(date +%Y%m%d)"
9092 git config user.name "github-actions[bot]"
9193 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"
9295 git checkout -b "$BRANCH_NAME"
9396 echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
9497
@@ -100,17 +103,21 @@ jobs:
100103 CI : ' true'
101104 GITHUB_ACTIONS : ' true'
102105 run : |
103- set -o pipefail
104106 if [ -z "$ANTHROPIC_API_KEY" ]; then
105- echo "⚠️ ANTHROPIC_API_KEY not set - skipping automated update"
107+ echo "ANTHROPIC_API_KEY not set - skipping automated update"
106108 echo "success=false" >> $GITHUB_OUTPUT
107109 exit 0
108110 fi
109111
110- if claude --print --dangerously-skip-permissions \
112+ set +e
113+ claude --print --dangerously-skip-permissions \
111114 --model sonnet \
112115 "/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." \
113- 2>&1 | tee claude-output.log; then
116+ 2>&1 | tee claude-output.log
117+ CLAUDE_EXIT=${PIPESTATUS[0]}
118+ set -e
119+
120+ if [ "$CLAUDE_EXIT" -eq 0 ]; then
114121 echo "success=true" >> $GITHUB_OUTPUT
115122 else
116123 echo "success=false" >> $GITHUB_OUTPUT
@@ -128,11 +135,8 @@ jobs:
128135 - name : Push branch
129136 if : steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
130137 env :
131- GITHUB_TOKEN : ${{ github.token }}
132138 BRANCH_NAME : ${{ steps.branch.outputs.branch }}
133- run : |
134- git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
135- git push origin "$BRANCH_NAME"
139+ run : git push origin "$BRANCH_NAME"
136140
137141 - name : Create Pull Request
138142 if : steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
@@ -143,41 +147,65 @@ jobs:
143147 COMMITS=$(git log --oneline origin/main..HEAD)
144148 COMMIT_COUNT=$(git rev-list --count origin/main..HEAD)
145149
146- BODY=$(cat <<EOF
147- ## Weekly Dependency Update
148-
149- Automated weekly update of npm packages.
150-
151- ### Commits (${COMMIT_COUNT})
152-
153- <details>
154- <summary>View commit history</summary>
155-
156- \`\`\`
157- ${COMMITS}
158- \`\`\`
159-
160- </details>
161-
162- ---
163-
164- <sub>Generated by [weekly-update.yml](.github/workflows/weekly-update.yml)</sub>
165- EOF
166- )
167- # Strip leading whitespace from heredoc lines
168- BODY=$(echo "$BODY" | sed 's/^ //')
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>"
169162
170163 gh pr create \
171164 --title "chore(deps): weekly dependency update ($(date +%Y-%m-%d))" \
172- --body "$BODY " \
165+ --body "$PR_BODY " \
173166 --draft \
174167 --head "$BRANCH_NAME" \
175168 --base main
176169
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+
177181 - name : Upload Claude output
178182 if : always()
179183 uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
180184 with :
181185 name : claude-output-${{ github.run_id }}
182186 path : claude-output.log
183187 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