Skip to content

Update pre-commit fix workflow to automatically run on GitHub Copilot PRs#698

Merged
A1L13N merged 2 commits into
mainfrom
copilot/fix-f96eea0c-278d-401e-941a-f055bc7cfb5c
Oct 5, 2025
Merged

Update pre-commit fix workflow to automatically run on GitHub Copilot PRs#698
A1L13N merged 2 commits into
mainfrom
copilot/fix-f96eea0c-278d-401e-941a-f055bc7cfb5c

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 5, 2025

Problem

The pre-commit fix GitHub Action was only configured to run via manual workflow_dispatch trigger. This meant that pull requests created by GitHub Copilot (which follow the copilot/* branch naming pattern) did not automatically benefit from pre-commit hook fixes, requiring manual intervention to apply formatting and linting corrections.

Solution

Updated .github/workflows/pre-commit.yml to automatically trigger on pull requests from Copilot branches while maintaining backward compatibility with manual runs.

Key Changes

  1. Added pull_request_target trigger - The workflow now triggers automatically when Copilot PRs are opened, synchronized, or reopened

  2. Copilot branch detection - Added logic to identify branches matching the copilot/* pattern, ensuring the workflow only runs on Copilot-generated PRs (not on all PRs)

  3. Smart checkout and push - Updated the workflow to properly check out PR head branches and push fixes back to the correct branch reference, handling both PR and manual trigger contexts

  4. Conditional execution - All workflow steps now conditionally execute based on branch detection, preventing unnecessary runs on non-Copilot PRs

How It Works

  • Copilot PRs: Automatically runs pre-commit hooks and pushes formatting fixes when PRs are created from copilot/* branches
  • Manual runs: Continues to work as before when triggered via workflow dispatch
  • Other PRs: Skips execution to avoid unnecessary resource usage and prevent interference with non-Copilot workflows

This implementation follows the same pattern used in enforce-issue-linked-pr.yml, ensuring consistency across repository workflows and improving the developer experience when working with GitHub Copilot.

Testing

The workflow has been validated for:

  • ✅ YAML syntax correctness
  • ✅ Proper conditional logic structure
  • ✅ Backward compatibility with existing workflow_dispatch trigger
  • ✅ Correct branch reference handling for both PR and manual contexts
Original prompt

Please update the Pre-commit fix GitHub action to work on pull requests from copilot


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 5, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

Free review on us!

CodeRabbit is offering free reviews until Wed Oct 08 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: A1L13N <193832434+A1L13N@users.noreply.github.com>
Copilot AI changed the title [WIP] Please update the Pre-commit fix GitHub action to work on pull requests from copilot Update pre-commit fix workflow to automatically run on GitHub Copilot PRs Oct 5, 2025
Copilot AI requested a review from A1L13N October 5, 2025 21:43
@A1L13N A1L13N marked this pull request as ready for review October 5, 2025 22:27
@A1L13N A1L13N merged commit ecd54d3 into main Oct 5, 2025
1 check passed
@A1L13N A1L13N deleted the copilot/fix-f96eea0c-278d-401e-941a-f055bc7cfb5c branch October 5, 2025 22:27
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