From b8b7af535efb08da563647ba2dc38da874381ba2 Mon Sep 17 00:00:00 2001 From: Adam Amer <136176500+adamamer20@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:33:35 +0100 Subject: [PATCH] added pr dependency-check fix dep. check fix dep. check fix dep. check fix dep. check fix dep. check fix dep. check fix dep. check fix dep. check fix dep. check fix dependency check added pr dependency-check --- .github/workflows/issues-dependency-check.yml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/issues-dependency-check.yml diff --git a/.github/workflows/issues-dependency-check.yml b/.github/workflows/issues-dependency-check.yml new file mode 100644 index 0000000..ba13f16 --- /dev/null +++ b/.github/workflows/issues-dependency-check.yml @@ -0,0 +1,43 @@ +name: Issues Dependency Check +on: + pull_request: + types: [opened, synchronize, reopened, edited] + pull_request_review: + types: [submitted, edited, dismissed] +jobs: + check-dependencies: + runs-on: ubuntu-latest + steps: + - name: Check for unresolved dependencies + uses: actions/github-script@v7 + with: + script: | + // Updated regex to match multiple issue numbers + const issueRegex = /depends on #(\\d+(?:\\s+#\\d+)*)/ig; + + async function run() { + let match; + let blockingIssues = []; + + // Find issues mentioned in the description + while ((match = issueRegex.exec(context.payload.body)) !== null) { + const issues = match[1].split(/\\s+#/); + for (const issueNumber of issues) { + const { data: issue } = await github.rest.issues.get({ + owner: adamamer20, + repo: mesa_frames, + issue_number: parseInt(issueNumber), + }); + + if (issue.state === 'open') { + blockingIssues.push(issueNumber); + } + } + } + + if (blockingIssues.length > 0) { + core.setFailed(`Cannot merge PR because these issues are not resolved: #${blockingIssues.join(', #')}`); + } + } + + run().catch(error => core.setFailed(error.message)); \ No newline at end of file