88 check-redirects :
99 name : Check redirects for renamed files
1010 runs-on : ubuntu-latest
11+ continue-on-error : true # Fail the check but don't block merge
1112 permissions :
1213 contents : read
1314 pull-requests : write
@@ -42,22 +43,23 @@ jobs:
4243 echo "$OUTPUT"
4344
4445 # Extract JSON output if present
45- if echo "$OUTPUT" | grep -Fq "---JSON_OUTPUT---"; then
46+ HAS_JSON=false
47+ if echo "$OUTPUT" | grep -Fq -- "---JSON_OUTPUT---"; then
4648 JSON_OUTPUT=$(echo "$OUTPUT" | sed -n '/---JSON_OUTPUT---/,/---JSON_OUTPUT---/p' | sed '1d;$d')
4749 echo "validation_result<<EOF" >> $GITHUB_OUTPUT
4850 echo "$JSON_OUTPUT" >> $GITHUB_OUTPUT
4951 echo "EOF" >> $GITHUB_OUTPUT
50- echo "has_results=true" >> $GITHUB_OUTPUT
51- else
52- echo "has_results=false" >> $GITHUB_OUTPUT
52+ HAS_JSON=true
5353 fi
5454
55- # Save exit code
55+ echo "has_results=$HAS_JSON" >> $GITHUB_OUTPUT
5656 echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
5757
5858 - name : Post comment if redirects are missing
5959 if : steps.validate.outputs.exit_code == '1' && steps.validate.outputs.has_results == 'true'
6060 uses : actions/github-script@v7
61+ env :
62+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6163 with :
6264 script : |
6365 const validationResultJson = `${{ steps.validate.outputs.validation_result }}`;
@@ -108,7 +110,7 @@ jobs:
108110 }
109111
110112 comment += '---\n';
111- comment += '_Note: This is a warning and will not block your PR. However, adding redirects ensures old links continue to work._\n';
113+ comment += '_Note: This check will fail until redirects are added. Adding redirects ensures old links continue to work._\n';
112114
113115 // Check for existing comments from this action
114116 const {data: comments} = await github.rest.issues.listComments({
@@ -119,6 +121,7 @@ jobs:
119121
120122 const existingComment = comments.find(comment =>
121123 comment.user.type === 'Bot' &&
124+ (comment.user.login === 'github-actions[bot]' || comment.user.login.includes('bot')) &&
122125 comment.body.includes('Missing Redirects Detected')
123126 );
124127
@@ -130,6 +133,7 @@ jobs:
130133 comment_id: existingComment.id,
131134 body: comment,
132135 });
136+ console.log(`Updated existing comment ${existingComment.id}`);
133137 } else {
134138 // Create new comment
135139 await github.rest.issues.createComment({
@@ -138,4 +142,17 @@ jobs:
138142 issue_number: context.issue.number,
139143 body: comment,
140144 });
145+ console.log('Created new comment');
141146 }
147+
148+ - name : Report failure if redirects are missing
149+ if : steps.validate.outputs.exit_code == '1' && steps.validate.outputs.has_results == 'true'
150+ run : |
151+ echo "::warning::Missing redirects detected. Please add the redirects shown in the PR comment above."
152+ echo "::warning::This check will show as failed, but will not block merging. However, adding redirects is recommended."
153+ exit 1
154+
155+ - name : Success - no redirects needed
156+ if : steps.validate.outputs.exit_code == '0'
157+ run : |
158+ echo "✅ No file renames detected, or all renames have corresponding redirects."
0 commit comments