@@ -130,6 +130,7 @@ jobs:
130130 echo "::error::1. Link via GitHub UI: Go to PR → Development section → Link issue"
131131 echo "::error::2. Add 'fixes #123' (or closes/resolves) to PR body, or"
132132 echo "::error::3. Use branch naming like 'issue-123-feature' or '123-feature'"
133+ echo "failure_detected=true" >> "$GITHUB_OUTPUT"
133134 exit 1
134135 fi
135136
@@ -256,4 +257,50 @@ jobs:
256257 echo "Added issue #$issue_number reference to PR #$pr_number body"
257258 else
258259 echo "Issue #$issue_number already referenced in PR #$pr_number body"
259- fi
260+ fi
261+
262+ - name : Add failure comment to PR
263+ if : failure() && steps.determine_issue.outputs.failure_detected == 'true'
264+ run : |
265+ pr_url="${{ inputs.pr_url }}"
266+ pr_number=$(echo "$pr_url" | grep -o '[0-9]*$')
267+
268+ comment_body=$(cat <<'EOF'
269+ # # ❌ Issue Linking Required
270+
271+ This PR could not be linked to an issue. **All PRs must be linked to an issue** for tracking purposes.
272+
273+ # ## How to fix this:
274+
275+ **Option 1: Link via GitHub UI** (Recommended)
276+ 1. Go to the PR → Development section (right sidebar)
277+ 2. Click "Link issue" and select an existing issue
278+
279+ **Option 2: Add keyword to PR body**
280+ Edit this PR's description and add one of these lines :
281+ - `This PR fixes : # 123`
282+ - `This PR closes : # 123`
283+ - `This PR resolves : # 123`
284+
285+ **Option 3: Use branch naming**
286+ Create a new branch with one of these patterns :
287+ - ` issue-123-feature-description`
288+ - ` 123-feature-description`
289+ - ` feature-issue-123-description`
290+
291+ # ## Why is this required?
292+ Issue linking ensures proper tracking, documentation, and helps maintain project history. It connects your code changes to the problem they solve.
293+
294+ ---
295+ *This comment was automatically generated by the issue linking workflow*
296+ EOF
297+ )
298+
299+ curl -X POST \
300+ -H "Accept : application/vnd.github+json" \
301+ -H "Authorization : Bearer ${{ env.GH_TOKEN }}" \
302+ -H "X-GitHub-Api-Version : 2022-11-28" \
303+ " https://api.github.com/repos/${{ github.repository }}/issues/$pr_number/comments" \
304+ -d "{\"body\":$(echo "$comment_body" | jq -R -s .)}"
305+
306+ echo "Added failure comment to PR # $pr_number"
0 commit comments