From b914a46c27b7ca061f1c0273d3f4c63f304bb72d Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 19 Apr 2024 14:59:42 -0400 Subject: [PATCH] milestone/changelog checkers adopted from jdaviz Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- .github/workflows/check_changelog.yml | 20 ++++++++++++++++ .github/workflows/check_milestone.yml | 34 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/check_changelog.yml create mode 100644 .github/workflows/check_milestone.yml diff --git a/.github/workflows/check_changelog.yml b/.github/workflows/check_changelog.yml new file mode 100644 index 00000000..b533c93a --- /dev/null +++ b/.github/workflows/check_changelog.yml @@ -0,0 +1,20 @@ +name: Check PR change log + +on: + pull_request: + types: [opened, synchronize, labeled, unlabeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + changelog_checker: + name: Check if change log entry is correct + runs-on: ubuntu-latest + steps: + - name: Check change log entry + uses: scientific-python/action-check-changelogfile@0.3 + env: + CHANGELOG_FILENAME: CHANGES.rst + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/check_milestone.yml b/.github/workflows/check_milestone.yml new file mode 100644 index 00000000..c23d3d67 --- /dev/null +++ b/.github/workflows/check_milestone.yml @@ -0,0 +1,34 @@ +name: Check PR milestone + +on: + # So it cannot be skipped. + pull_request_target: + types: [opened, synchronize, milestoned, demilestoned] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + # https://stackoverflow.com/questions/69434370/how-can-i-get-the-latest-pr-data-specifically-milestones-when-running-yaml-jobs + milestone_checker: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + if: github.repository == 'spacetelescope/lcviz' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + 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 maintainer needs to set the milestone for this pull request.`); + }