Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

Auto-label PRs based on pre-commit check results for better visibility of code quality status.

Changes

  • Added label automation step to pre-commit job in .github/workflows/ci-cd.yml
  • Labels applied:
    • pre-commit: passed (green #0e8a16) on success
    • pre-commit: failed (red #e74c3c) on failure
  • Auto-removes stale pre-commit labels when status changes
  • Creates labels on-demand if missing from repository

Implementation

Uses github-script@v7 to manage labels via GitHub API, following the same pattern as existing label workflows (add-files-changed-label.yml, add-comment-count-label.yml). Runs only on pull_request events after pre-commit step completes.

- name: Add pre-commit status label
  if: github.event_name == 'pull_request'
  uses: actions/github-script@v7
  with:
    script: |
      const preCommitOutcome = '${{ steps.pre-commit.outcome }}';
      const newLabel = preCommitOutcome === 'success' 
        ? 'pre-commit: passed' 
        : 'pre-commit: failed';
      // ... label management logic
Original prompt

On the pre commit github action add a lable to the pr if it passes or not a


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 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.


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

@github-actions github-actions bot added the unresolved-conversations: 0 PR has 0 unresolved conversations label Nov 16, 2025
@DonnieBLT DonnieBLT marked this pull request as ready for review November 16, 2025 06:19
@github-actions github-actions bot added the files-changed: 0 PR changes 0 files label Nov 16, 2025
Copilot AI changed the title [WIP] Add label to PR based on status of pre-commit action Add pre-commit status labels to pull requests Nov 16, 2025
Copilot AI requested a review from DonnieBLT November 16, 2025 06:23
@github-actions github-actions bot added files-changed: 1 pre-commit: passed Pre-commit checks passed and removed files-changed: 0 PR changes 0 files labels Nov 16, 2025
@github-actions
Copy link
Contributor

❌ Pre-commit checks failed

The pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them:

# Install pre-commit if you haven't already
pip install pre-commit

# Run pre-commit on all files
pre-commit run --all-files

# Or run pre-commit on staged files only
pre-commit run

After running these commands, the pre-commit hooks will automatically fix most issues.
Please review the changes, commit them, and push to your branch.

💡 Tip: You can set up pre-commit to run automatically on every commit by running:

pre-commit install

For more information, see the pre-commit documentation.

@github-actions github-actions bot added pre-commit: failed Pre-commit checks failed and removed pre-commit: passed Pre-commit checks passed labels Nov 16, 2025
@DonnieBLT DonnieBLT merged commit 0f30be3 into main Nov 16, 2025
14 of 16 checks passed
@DonnieBLT DonnieBLT deleted the copilot/add-pr-label-on-status branch November 16, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

files-changed: 1 pre-commit: failed Pre-commit checks failed unresolved-conversations: 0 PR has 0 unresolved conversations

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants