Bump astro from 4.16.18 to 4.16.19 in /examples/ecommerce-support-simulator/resources/ui #158
Workflow file for this run
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: PR Issue Link Checker | |
on: | |
pull_request: | |
types: [opened, edited, reopened, synchronize] | |
jobs: | |
check-issue-link: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for Linked Issue | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { owner, repo, number } = context.issue; | |
// Get the PR details | |
const pr = await github.rest.pulls.get({ | |
owner, | |
repo, | |
pull_number: number | |
}); | |
// Check PR body for issue links | |
const body = pr.data.body || ''; | |
// Regular expressions to match different formats of issue links | |
const issueRegexes = [ | |
/#(\d+)/, // #123 | |
/[Cc]loses #(\d+)/, // Closes #123 | |
/[Ff]ixes #(\d+)/, // Fixes #123 | |
/[Rr]esolves #(\d+)/, // Resolves #123 | |
/[Cc]lose #(\d+)/, // Close #123 | |
/[Ff]ix #(\d+)/, // Fix #123 | |
/[Rr]esolve #(\d+)/, // Resolve #123 | |
/[Cc]loses: #(\d+)/, // Closes: #123 | |
/[Ff]ixes: #(\d+)/, // Fixes: #123 | |
/[Rr]esolves: #(\d+)/, // Resolves: #123 | |
/[Cc]lose: #(\d+)/, // Close: #123 | |
/[Ff]ix: #(\d+)/, // Fix: #123 | |
/[Rr]esolve: #(\d+)/, // Resolve: #123 | |
/(?:issues?|closes?|fixes?|resolves?)[ ]*?(?:\/|#)(\d+)/i // Various other formats | |
]; | |
let hasIssueLink = false; | |
// Also check if the PR is linked to issues through GitHub's UI | |
const linkedIssues = await github.rest.issues.listEventsForTimeline({ | |
owner, | |
repo, | |
issue_number: number | |
}); | |
const crossReferences = linkedIssues.data.filter(event => | |
event.event === 'cross-referenced' && | |
event.source?.issue?.html_url.includes(`/${owner}/${repo}/issues/`) | |
); | |
if (crossReferences.length > 0) { | |
hasIssueLink = true; | |
} | |
// Check for issue links in PR body | |
if (!hasIssueLink) { | |
for (const regex of issueRegexes) { | |
if (regex.test(body)) { | |
hasIssueLink = true; | |
break; | |
} | |
} | |
} | |
if (!hasIssueLink) { | |
core.setFailed('Pull request must be linked to an issue. Please add a reference to an issue in your PR description (e.g., "Fixes #123") or link an issue through the GitHub UI.'); | |
} |