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

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

Plan: Add PR Conflict Detection GitHub Action ✅

  • Analyze existing GitHub Actions workflows to understand patterns
  • Create new workflow file: check-pr-conflicts.yml
  • Implement conflict detection using GitHub API
  • Add/remove "has-conflicts" label based on PR mergeable state
  • Add comment to PR author when conflicts are detected
  • Only add one comment (check for existing comment before adding new one)
  • Remove comment when conflicts are resolved
  • Validate YAML syntax
  • Run security check (CodeQL)
  • Review and finalize

Summary

Successfully created a GitHub Action workflow that automatically:

  1. Detects merge conflicts in pull requests using the GitHub API
  2. Adds a has-conflicts label (in red #e74c3c color) when conflicts are detected
  3. Posts a helpful comment to the PR author with clear instructions on how to resolve conflicts
  4. Removes both the label and comment when conflicts are resolved
  5. Runs on PR events (opened, synchronize, reopened, ready_for_review)

Key Features:

  • ✅ Uses pull_request_target for security (doesn't execute PR code from forks)
  • ✅ Uses a unique HTML comment marker (<!-- pr-conflict-check -->) to prevent duplicate comments
  • ✅ Creates the label automatically if it doesn't exist
  • ✅ Properly handles cleanup when conflicts are resolved
  • ✅ Provides clear, actionable instructions for resolving conflicts
  • ✅ Uses the project's preferred red color (#e74c3c) for the conflict label
  • ✅ Follows the same patterns as other workflows in the repository

Security Summary:

✅ No security vulnerabilities detected by CodeQL
✅ Workflow follows security best practices by using pull_request_target without checking out PR code

The workflow is ready to use and will automatically start working once merged to the main branch!

Original prompt

add a github action that will attach a lable to a PR if it has conflicts and remove it if there are no conflicts - also have it add a note to the author


✨ 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
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
Copy link
Collaborator

@copilot try again

Copy link
Contributor Author

Copilot AI commented Nov 16, 2025

@copilot try again

I've simplified the workflow to better match the patterns used by other workflows in the repository:

Changes made in commit 26a2575:

  • Removed the push event trigger that was attempting to check all open PRs when base branches were updated
  • Simplified the script to only process the current PR from the event context
  • Fixed indentation and reduced complexity

The workflow now:

  • Only triggers on PR events (opened, synchronize, reopened, ready_for_review)
  • Follows the same pattern as add-comment-count-label.yml and other similar workflows
  • Is more focused and efficient

The workflow is validated, has no security issues, and is ready to use.

Copilot AI changed the title [WIP] Add GitHub Action for handling PR conflicts Add GitHub Action for handling PR conflicts Nov 16, 2025
@DonnieBLT DonnieBLT marked this pull request as ready for review November 16, 2025 22:06
@DonnieBLT DonnieBLT merged commit 31edd1e into main Nov 16, 2025
13 checks passed
@DonnieBLT DonnieBLT deleted the copilot/add-github-action-label-on-conflict branch November 16, 2025 22:06
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

files-changed: 1 unresolved-conversations: 0 PR has 0 unresolved conversations

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants