From 3e3522e6ee465e8cbd21d7567bf335dc8dfebb9f Mon Sep 17 00:00:00 2001 From: sahani-deriv Date: Wed, 26 Jun 2024 13:29:21 +0800 Subject: [PATCH] ci: add workflow to check if versioning pr exists --- .github/workflows/check_versioning_pr.yml | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/check_versioning_pr.yml diff --git a/.github/workflows/check_versioning_pr.yml b/.github/workflows/check_versioning_pr.yml new file mode 100644 index 000000000..5da79886e --- /dev/null +++ b/.github/workflows/check_versioning_pr.yml @@ -0,0 +1,43 @@ +name: versioning_pr_exists + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + check-version-pr: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "14" + + - name: Check if PR with title chore(version) exists + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.PAT }} + script: | + const { data: pullRequests } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + per_page: 100 + }); + + const existingPR = pullRequests.find(pr => pr.title === 'chore(version): bump version and update changelog'); + + if (existingPR) { + core.setFailed(`Version bump pull request exists. Please merge that pr first to pass the check.: #${existingPR.number}`); + } else { + console.log("No version bump pull request found."); + } + + - name: Fail if PR exists + if: steps.check-pr.outputs.exists == 'true' + run: | + echo "Version bump pull request exists. Please merge that pr first to pass the check." + exit 1