From 87f439a2f1158fe5f60fdd588077d0b9d6b98997 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Wed, 4 Dec 2024 20:31:39 -0500 Subject: [PATCH] add in changelog entry check --- .github/workflows/_changelog-entry-check.yml | 57 ++++++++++++++++++++ .github/workflows/pull-request-checks.yml | 7 ++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/_changelog-entry-check.yml diff --git a/.github/workflows/_changelog-entry-check.yml b/.github/workflows/_changelog-entry-check.yml new file mode 100644 index 00000000..93f453c0 --- /dev/null +++ b/.github/workflows/_changelog-entry-check.yml @@ -0,0 +1,57 @@ +name: "Changelog entry check" + +on: + workflow_call: + inputs: + package: + description: "Choose the package to test" + type: string + default: "dbt-adapters" + issue: + description: "The issue/PR number" + type: string + required: true + +permissions: + contents: read + pull-requests: write + +jobs: + changelog-check: + if: ${{ !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') }} + outputs: + exists: ${{ steps.changelog.outputs.exists }} + runs-on: ubuntu-latest + steps: + - id: changelog + uses: dorny/paths-filter@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + filters: | + exists: + - added|modified: '${{ inputs.package }}/.changes/unreleased/**.yaml' + + comment: + needs: changelog-check + if: needs.changelog-check.outputs.exists == false + runs-on: ubuntu-latest + env: + COMMENT: >- + Thank you for your pull request! We could not find a changelog entry for this change. + For details on how to document a change, see the + [Contributing Guide](https://github.com/dbt-labs/dbt-adapters/blob/main/CONTRIBUTING.md). + steps: + - id: comment + uses: peter-evans/find-comment@v3 + with: + issue-number: ${{ inputs.issue }} + comment-author: "github-actions[bot]" + body-includes: ${{ env.COMMENT }} + - if: steps.comment.outputs.comment-body == '' + run: gh issue comment ${{ inputs.issue }} --repo ${{ github.repository }} --body "${{ env.COMMENT }}" + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/github-script@v7 + with: + script: core.setFailed('Changelog entry required to merge.') diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index 354995d5..7f345a04 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -2,7 +2,7 @@ name: "Pull request checks" on: pull_request_target: - types: [opened, reopened, synchronize] + types: [opened, reopened, synchronize, labeled, unlabeled] # only run this once per PR at a time concurrency: @@ -10,6 +10,11 @@ concurrency: cancel-in-progress: true jobs: + changelog-entry: + uses: ./.github/workflows/_changelog-entry-check.yml + with: + issue: ${{ github.event.pull_request.number }} + code-quality: uses: ./.github/workflows/_code-quality.yml with: