Skip to content

Commit

Permalink
update changelog entry check
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Dec 6, 2024
1 parent bcaaa09 commit bbdc016
Showing 1 changed file with 51 additions and 31 deletions.
82 changes: 51 additions & 31 deletions .github/workflows/_changelog-entry-check.yml
Original file line number Diff line number Diff line change
@@ -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.')

0 comments on commit bbdc016

Please sign in to comment.