From bbdc016429670396961b16ba7a798292036d38d1 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 6 Dec 2024 18:12:22 -0500 Subject: [PATCH] update changelog entry check --- .github/workflows/_changelog-entry-check.yml | 82 ++++++++++++-------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/.github/workflows/_changelog-entry-check.yml b/.github/workflows/_changelog-entry-check.yml index 8732177f..93f453c0 100644 --- a/.github/workflows/_changelog-entry-check.yml +++ b/.github/workflows/_changelog-entry-check.yml @@ -1,37 +1,57 @@ -# **what?** -# Checks that a file has been committed under the /.changes directory -# as a new CHANGELOG entry. Cannot check for a specific filename as -# it is dynamically generated by change type and timestamp. -# This workflow runs on pull_request_target because it requires -# secrets to post comments. - -# **why?** -# Ensure code change gets reflected in the CHANGELOG. - -# **when?** -# This will run for all PRs going into main. It will -# run when they are opened, reopened, when any label is added or removed -# and when new code is pushed to the branch. The action will get -# skipped if the 'Skip Changelog' label is present is any of the labels. - -name: Check Changelog Entry +name: "Changelog entry check" on: - pull_request_target: - types: [opened, reopened, labeled, unlabeled, synchronize] - -defaults: - run: - shell: bash + 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 + contents: read + pull-requests: write jobs: - changelog: - uses: dbt-labs/actions/.github/workflows/changelog-existence.yml@main - with: - changelog_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#adding-changelog-entry).' - skip_label: 'Skip Changelog' - secrets: inherit + 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.')