Skip to content

Commit

Permalink
[CI] Chore: Improve Linear Issue Check Syntax (#5508)
Browse files Browse the repository at this point in the history
CNCT-2462
<!-- start pr-codex -->

## PR-Codex overview
This PR introduces a new GitHub Actions workflow named `Linked Issue`, which checks for valid issue references in the pull request body. It ensures that the body contains an issue ID with specified prefixes before allowing the pull request to proceed.

### Detailed summary
- Added a new workflow file named `issue.yml`.
- Set the workflow to trigger on `pull_request` events (opened, edited).
- Defined an environment variable `VALID_ISSUE_PREFIXES` with values "CNCT|DASH".
- Created a job named `linear` that runs on `ubuntu-latest`.
- Implemented a step to check for linked issue references in the PR body using a regex.
- If no valid reference is found, the workflow fails with a specific error message.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
gregfromstl committed Nov 25, 2024
1 parent 46c3abb commit 0e98b09
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Linked Issue

on:
pull_request:
types: [opened, edited]

env:
VALID_ISSUE_PREFIXES: "CNCT|DASH"

jobs:
linear:
name: Linear
runs-on: ubuntu-latest
steps:
- name: Check for linked issue
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const body = pr.data.body || '';
const issueRegex = new RegExp(`(${process.env.VALID_ISSUE_PREFIXES})-\\d+`, 'i');
if (!issueRegex.test(body)) {
core.setFailed(
`No valid issue reference found. PR body must contain an issue ID with one of these prefixes: ${process.env.VALID_ISSUE_PREFIXES}`
);
return;
}
const matches = body.match(issueRegex);
console.log(`Found issue reference: ${matches[0]}`);
26 changes: 0 additions & 26 deletions .github/workflows/linear.yml

This file was deleted.

0 comments on commit 0e98b09

Please sign in to comment.