diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml new file mode 100644 index 00000000000..91280f7119d --- /dev/null +++ b/.github/workflows/issue.yml @@ -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]}`); diff --git a/.github/workflows/linear.yml b/.github/workflows/linear.yml deleted file mode 100644 index a0155d51161..00000000000 --- a/.github/workflows/linear.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Check for linked issue in pull request body - -on: - pull_request: - types: - - opened - - edited - -jobs: - check_linear_in_pr_body: - runs-on: ubuntu-latest - steps: - - name: Check for linked issue in pull request body - run: | - pr_body=$(curl -s \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }} | jq -r .body) - - echo "Pull Request Body: $pr_body" - - if echo "$pr_body" | grep -iE "CNCT|DASH|BLOCK"; then - echo "Linked issue found in the pull request body." - else - echo "No linked issue found in the pull request body." - exit 1 - fi