From b67141154f4feb9750bc92ff64e5edbac5cfd636 Mon Sep 17 00:00:00 2001 From: Mariam Fahmy Date: Sat, 30 Mar 2024 10:42:15 +0100 Subject: [PATCH] chore: add a job to check the PR milestone is set (#9966) * chore: add a job to check the PR milestone is set Signed-off-by: Mariam Fahmy * Update .github/workflows/check-milestone.yaml Co-authored-by: Vishal Choudhary Signed-off-by: Mariam Fahmy * Update .github/workflows/check-milestone.yaml Co-authored-by: Vishal Choudhary Signed-off-by: Mariam Fahmy * Update .github/workflows/check-milestone.yaml Co-authored-by: Vishal Choudhary Signed-off-by: Mariam Fahmy * fix: remove the release branch from the milestone check Signed-off-by: Mariam Fahmy --------- Signed-off-by: Mariam Fahmy Signed-off-by: Mariam Fahmy Co-authored-by: Vishal Choudhary --- .github/workflows/check-milestone.yaml | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/check-milestone.yaml diff --git a/.github/workflows/check-milestone.yaml b/.github/workflows/check-milestone.yaml new file mode 100644 index 000000000000..3789f4dfd6a0 --- /dev/null +++ b/.github/workflows/check-milestone.yaml @@ -0,0 +1,33 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: check-milestone + +permissions: {} + +on: + pull_request: + branches: + - 'main' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-milestone: + runs-on: ubuntu-latest + steps: + - name: Check milestone + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const { data } = await github.request("GET /repos/{owner}/{repo}/pulls/{pr}", { + owner: context.repo.owner, + repo: context.repo.repo, + pr: context.payload.pull_request.number + }); + if (data.milestone) { + core.info(`This pull request has a milestone set: ${data.milestone.title}`); + } else { + core.setFailed(`A milestone need to be set on this pull request.`); + }