Skip to content

ADAP-1123: Create the package subdirectory #286

ADAP-1123: Create the package subdirectory

ADAP-1123: Create the package subdirectory #286

name: Changelog entry check
on:
pull_request:
types:
- opened
- reopened
- labeled
- unlabeled
- synchronize
defaults:
run:
shell: bash
working-directory: ./dbt-postgres
permissions:
contents: read
pull-requests: write
jobs:
changelog-entry-check:
name: Check if Changelog Exists
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') }}
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
[dbt-postgres contributing guide](https://github.com/dbt-labs/dbt-postgres/blob/main/CONTRIBUTING.md).
steps:
- name: Check if changelog file was added
# https://github.com/marketplace/actions/paths-changes-filter
# For each filter, it sets output variable named by the filter to the text:
# 'true' - if any of changed files matches any of filter rules
# 'false' - if none of changed files matches any of filter rules
uses: dorny/paths-filter@v3
id: changelog_check
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
exists:
- added|modified: 'dbt-postgres/.changes/unreleased/**.yaml'
# this step uses the read permission from the GITHUB_TOKEN it inherits
- name: Check for comment
if: steps.changelog_check.outputs.exists == 'false'
uses: peter-evans/find-comment@v3
id: changelog_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: ${{ env.COMMENT }}
- name: Set if comment already exists
if: steps.changelog_check.outputs.exists == 'false'
shell: bash
id: comment_check
run: |
if [ '${{ steps.changelog_comment.outputs.comment-body }}' = '' ]; then
echo "exists=false" >> $GITHUB_OUTPUT
echo "Comment does not exist for this PR"
else
echo "exists=true" >> $GITHUB_OUTPUT
echo "Comment already exists for this PR"
fi
# this step uses the write permission on the PR from the GITHUB_TOKEN it inherits
- name: Create PR comment if changelog entry is missing, required, and does not exist
if: |
steps.changelog_check.outputs.exists == 'false' &&
steps.comment_check.outputs.exists == 'false'
run: |
gh issue comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "${{ env.COMMENT }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail job if changelog entry is missing and required
if: steps.changelog_check.outputs.exists == 'false'
uses: actions/github-script@v7
with:
script: core.setFailed('Changelog entry required to merge.')