feat: add watchlist component #3508
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'Tools: PR Conflict Checker' | |
| on: | |
| pull_request_target: | |
| types: | |
| - 'opened' | |
| - 'synchronize' | |
| - 'reopened' | |
| branches: | |
| - 'master' | |
| - 'v5.*' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-conflicts: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Checkout PR head | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0 | |
| with: | |
| files: '**' | |
| - name: Check for conflict markers | |
| id: conflict-check | |
| run: | | |
| echo "Checking for conflict markers in changed files..." | |
| CONFLICT_FILES="" | |
| HAS_CONFLICTS=false | |
| # Check each changed file for conflict markers | |
| for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | |
| if [ -f "$file" ]; then | |
| echo "Checking file: $file" | |
| # Look for conflict markers (more precise regex) | |
| if grep -qE '^(<<<<<<<|=======|>>>>>>>)' "$file" 2>/dev/null; then | |
| echo "Conflict markers found in: $file" | |
| CONFLICT_FILES="${CONFLICT_FILES}- \`${file}\`"$'\n' | |
| HAS_CONFLICTS=true | |
| fi | |
| fi | |
| done | |
| if [ "$HAS_CONFLICTS" = true ]; then | |
| echo "has_conflicts=true" >> $GITHUB_OUTPUT | |
| { | |
| echo "conflict_files<<EOF" | |
| echo "$CONFLICT_FILES" | |
| echo "EOF" | |
| } >> $GITHUB_OUTPUT | |
| echo "Conflict markers detected" | |
| else | |
| echo "has_conflicts=false" >> $GITHUB_OUTPUT | |
| echo "No conflict markers found in changed files" | |
| fi | |
| - name: Manage conflict label | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| HAS_CONFLICTS: ${{ steps.conflict-check.outputs.has_conflicts }} | |
| run: | | |
| LABEL_NAME="has-conflicts" | |
| # Add or remove label based on conflict status | |
| if [ "$HAS_CONFLICTS" = "true" ]; then | |
| echo "Adding conflict label to PR #${PR_NUMBER}..." | |
| gh pr edit "$PR_NUMBER" --add-label "$LABEL_NAME" --repo ${{ github.repository }} || true | |
| else | |
| echo "Removing conflict label from PR #${PR_NUMBER}..." | |
| gh pr edit "$PR_NUMBER" --remove-label "$LABEL_NAME" --repo ${{ github.repository }} || true | |
| fi | |
| - name: Find existing comment | |
| uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0 | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: '<!-- conflict-checker-comment -->' | |
| - name: Create or update comment | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 | |
| with: | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| edit-mode: replace | |
| body: | | |
| <!-- conflict-checker-comment --> | |
| ${{ steps.conflict-check.outputs.has_conflicts == 'true' && '⚠️ **Conflict Markers Detected**' || '✅ **Conflict Markers Resolved**' }} | |
| ${{ steps.conflict-check.outputs.has_conflicts == 'true' && format('This pull request contains unresolved conflict markers in the following files: | |
| {0} | |
| Please resolve these conflicts by: | |
| 1. Locating the conflict markers: `<<<<<<<`, `=======`, and `>>>>>>>` | |
| 2. Manually editing the files to resolve the conflicts | |
| 3. Removing all conflict markers | |
| 4. Committing and pushing the changes', steps.conflict-check.outputs.conflict_files) || 'All conflict markers have been successfully resolved in this pull request.' }} | |
| - name: Fail workflow if conflicts detected | |
| if: steps.conflict-check.outputs.has_conflicts == 'true' | |
| run: | | |
| echo "::error::Workflow failed due to conflict markers detected in the PR" | |
| exit 1 |