Skip to content

Commit 6c210f1

Browse files
jeremyederclaude
andauthored
fix(workflows): improve Amber no-changes detection and reporting (#386)
## Summary Fixes the Amber workflow error that occurred in run #19752601200 where PR creation failed with "No commits between main and branch" error. ## Problem When Claude Code ran but didn't make any commits (e.g., files already properly formatted), the workflow would fail because it used `git diff --quiet HEAD~1` which doesn't work correctly on a new branch with no commits beyond the base. ## Changes 1. **Better change detection**: Now counts commits ahead of `origin/main` using `git rev-list --count` instead of comparing to `HEAD~1` 2. **User feedback**: When no changes are needed, posts an informative comment to the issue explaining possible reasons 3. **Prevents failures**: Skips PR creation entirely when there are no actual commits to push ## Testing This will be tested when issue #384 is re-triggered after merge. ## Related Issues - Fixes the error from workflow run: https://github.com/ambient-code/platform/actions/runs/19752601200 - Related to issue #384 --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8b55e1e commit 6c210f1

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

.github/workflows/amber-issue-handler.yml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,24 +222,55 @@ jobs:
222222
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
223223
run: |
224224
# Run Claude Code with full tool access (you make the rules!)
225-
claude --batch --dangerously-skip-permissions amber-prompt.md || true
225+
cat amber-prompt.md | claude --print --dangerously-skip-permissions || true
226226
echo "Claude Code execution completed"
227227
228228
- name: Check if changes were made
229229
id: check-changes
230230
run: |
231-
if git diff --quiet HEAD~1 2>/dev/null; then
231+
# Check if there are any new commits on this branch vs main
232+
CURRENT_BRANCH=$(git branch --show-current)
233+
COMMITS_AHEAD=$(git rev-list --count origin/main.."$CURRENT_BRANCH" 2>/dev/null || echo "0")
234+
235+
if [ "$COMMITS_AHEAD" -eq 0 ]; then
232236
echo "has_changes=false" >> $GITHUB_OUTPUT
233-
echo "No changes made by Amber"
237+
echo "No changes made by Amber (no new commits)"
234238
else
235239
COMMIT_SHA=$(git rev-parse HEAD)
236-
BRANCH_NAME=$(git branch --show-current)
237240
echo "has_changes=true" >> $GITHUB_OUTPUT
238-
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
241+
echo "branch_name=$CURRENT_BRANCH" >> $GITHUB_OUTPUT
239242
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
240-
echo "Changes committed on branch $BRANCH_NAME (commit: ${COMMIT_SHA:0:7})"
243+
echo "Changes committed on branch $CURRENT_BRANCH (commit: ${COMMIT_SHA:0:7})"
244+
echo "Commits ahead of main: $COMMITS_AHEAD"
241245
fi
242246
247+
- name: Report no changes
248+
if: steps.check-changes.outputs.has_changes == 'false'
249+
env:
250+
ISSUE_NUMBER: ${{ steps.issue-details.outputs.issue_number }}
251+
ACTION_TYPE: ${{ steps.action-type.outputs.type }}
252+
uses: actions/github-script@v7
253+
with:
254+
script: |
255+
const issueNumber = parseInt(process.env.ISSUE_NUMBER);
256+
const actionType = process.env.ACTION_TYPE;
257+
258+
await github.rest.issues.createComment({
259+
owner: context.repo.owner,
260+
repo: context.repo.repo,
261+
issue_number: issueNumber,
262+
body: `✅ Amber reviewed this issue but found no changes were needed.
263+
264+
**Action Type:** ${actionType}
265+
266+
**Possible reasons:**
267+
- Files are already properly formatted
268+
- No linting issues found
269+
- The requested changes may have already been applied
270+
271+
If you believe changes are still needed, please provide more specific instructions or file paths in the issue description.`
272+
});
273+
243274
- name: Push branch to remote
244275
if: steps.check-changes.outputs.has_changes == 'true'
245276
env:

0 commit comments

Comments
 (0)