fix(ui): enforce 100-char limit on mute rule name input #9761
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: | |
| # zizmor: ignore[dangerous-triggers] - intentional: needs write access for conflict labels/comments, checkout uses PR head SHA for read-only grep | |
| pull_request_target: | |
| types: | |
| - 'opened' | |
| - 'synchronize' | |
| - 'reopened' | |
| branches: | |
| - 'master' | |
| - 'v5.*' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| jobs: | |
| check-conflicts: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout PR head | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 1 | |
| # zizmor: ignore[artipacked] | |
| persist-credentials: true # Required by tj-actions/changed-files to fetch PR branch | |
| - name: Fetch PR base ref for tj-actions/changed-files | |
| env: | |
| BASE_REF: ${{ github.event.pull_request.base.ref }} | |
| run: git fetch --depth=1 origin "${BASE_REF}" | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5 | |
| 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 | |
| env: | |
| STEPS_CHANGED_FILES_OUTPUTS_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
| - 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 |