Skip to content

Skip push/PR creation when formatting produces no changes#13

Merged
markgaze merged 1 commit intomainfrom
copilot/fix-branch-push-logic
Apr 21, 2026
Merged

Skip push/PR creation when formatting produces no changes#13
markgaze merged 1 commit intomainfrom
copilot/fix-branch-push-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

The format action was unconditionally committing and pushing (or creating a PR) after running the format command, even when no files were modified — wasting build minutes on a no-op push.

Changes

  • format/action.yml: Added a Check for changes step that runs git diff --quiet post-format and sets a detected output
  • Both Commit changes and Create Pull Request steps are now gated on steps.changes.outputs.detected == 'true', so neither runs when formatting is already clean
- name: Check for changes
  id: changes
  run: |
    if git diff --quiet; then
      echo "detected=false" >> "$GITHUB_OUTPUT"
    else
      echo "detected=true" >> "$GITHUB_OUTPUT"
    fi
  shell: bash

- name: Commit changes
  if: ${{ inputs.create-pr != 'true' && steps.changes.outputs.detected == 'true' }}
  ...

- name: Create Pull Request
  if: ${{ inputs.create-pr == 'true' && steps.changes.outputs.detected == 'true' }}
  ...

@markgaze markgaze marked this pull request as ready for review April 21, 2026 10:34
@markgaze markgaze merged commit ffbd97a into main Apr 21, 2026
2 checks passed
@markgaze markgaze deleted the copilot/fix-branch-push-logic branch April 21, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants