You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# so the maintainer isn't left guessing from Action logs alone.
177
+
trap 'code=$?; if [[ $code -ne 0 && $REPORTED -eq 0 ]]; then
178
+
gh pr comment "$PR_NUMBER" --body "❌ Failed to open follow-up PR with the Claude edits — see [workflow run]($RUN_URL)." >/dev/null 2>&1 || true;
179
+
fi' EXIT
180
+
181
+
# Only consider edits under the allowed paths. The post-checkout hook
182
+
# installed earlier touches CLAUDE.md / .claude/ at the repo root —
183
+
# those are workflow artifacts, not Claude's edits, so we ignore them.
184
+
if [[ -z "$(git status --porcelain -- .ai src/diffusers)" ]]; then
185
+
post_status "ℹ️ \`COMMIT THIS\` was requested, but Claude didn't edit any files under \`.ai/\` or \`src/diffusers/\`, so no follow-up PR was opened. See [workflow run]($RUN_URL)."
186
+
exit 0
187
+
fi
188
+
189
+
# For fork PRs, an earlier step redirected `origin` to a local bare
190
+
# repo to sandbox claude-code-action. Undo that redirect so our push
191
+
# reaches the real base repo. Safe: only Claude's edits within the
192
+
# allowed paths are committed below — never the fork's other changes.
git commit -m "Apply changes from Claude (requested by @${COMMENT_USER} on #${PR_NUMBER})
231
+
232
+
Co-Authored-By: Claude <noreply@anthropic.com>"
233
+
CLAUDE_COMMIT=$(git rev-parse HEAD)
234
+
235
+
git fetch --depth=1 origin "$BASE_BRANCH"
236
+
git switch -c "$NEW_BRANCH" "origin/$BASE_BRANCH"
237
+
if ! git cherry-pick "$CLAUDE_COMMIT"; then
238
+
git cherry-pick --abort 2>/dev/null || true
239
+
post_status "❌ Can't open follow-up PR against \`${BASE_BRANCH}\` — Claude's edits conflict with current \`${BASE_BRANCH}\`. Rebase #${PR_NUMBER} or apply manually. See [workflow run]($RUN_URL)."
240
+
exit 1
241
+
fi
242
+
243
+
git push -u origin "$NEW_BRANCH"
244
+
245
+
NEW_PR_URL=$(gh pr create \
246
+
--base "$BASE_BRANCH" \
247
+
--head "$NEW_BRANCH" \
248
+
--title "Apply Claude's changes from #${PR_NUMBER}" \
249
+
--body "Automated PR with edits Claude made in response to \`COMMIT THIS\` from @${COMMENT_USER} on [#${PR_NUMBER}](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}).
250
+
251
+
Targets \`${BASE_BRANCH}\` — independent of #${PR_NUMBER}. Further \`COMMIT THIS\` requests on *this* PR will commit directly to it.")
252
+
253
+
post_status "✅ Opened follow-up PR (into \`${BASE_BRANCH}\`) with Claude's edits: ${NEW_PR_URL}"
0 commit comments