From 478d12ff0b5795876a4bc11b3b0cc1e27949dd56 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 3 Dec 2024 11:57:05 +0100 Subject: [PATCH] Draft script to comment on missing CHANGELOG entry --- .github/workflows/ensure-changelog-entry.yml | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/ensure-changelog-entry.yml diff --git a/.github/workflows/ensure-changelog-entry.yml b/.github/workflows/ensure-changelog-entry.yml new file mode 100644 index 00000000000..b34a209c5fd --- /dev/null +++ b/.github/workflows/ensure-changelog-entry.yml @@ -0,0 +1,53 @@ +name: Check change log entry +on: + pull_request: + types: [opened, reopened, edited] + +jobs: + ensure_changelog_entry: + permissions: + contents: read + issues: write + runs-on: ubuntu-latest + steps: + - name: Find entry + uses: actions/github-script@v7 + id: found + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + // Groups: yes - 1, entry - 2, no - 3 + const regex = /\*\*CHANGELOG entry\*\*\s+(?:(yes|yeah)(?:\.\s*(.*))?|(no|nope|none)\.?)\s*(?:\*\*Additional Notes|\*\*How to test|\z)/mi + return context.payload.pull_request.body.match() + + - name: Notify on missing entry + uses: actions/github-script@v7 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + // Is author a part of the Datadog/ruby-guild + if (false) { + // Leave comment for Datadog/ruby-guild + // and then exit + + // return + } + + console.log(found) + + # If main response is missing + if (undefined == found.at(1) || undefined == found.at(3)) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ github.event.pull_request.number }}, + `Please fill CHANGELOG entry section. + + If your changes need mention in a CHANGELOG + > Yes. + + or as follows if they don't + > No. + `, + }) + }