Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions .github/workflows/check_for_changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,30 @@ jobs:
check-for-changeset:
name: Check for changeset
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
- name: 'Check for changeset'
uses: brettcannon/check-for-changed-files@v1
with:
file-pattern: '.changeset/*.md'
skip-label: 'skip changeset'
failure-message: 'No changeset found. If these changes should not result in a new version, apply the ${skip-label} label to this pull request. If these changes should result in a version bump, please add a changeset https://git.io/J6QvQ'
env:
Comment thread
joshblack marked this conversation as resolved.
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
SKIP_LABEL: 'skip changeset'
run: |
set -euo pipefail

if jq -r '.pull_request.labels[]?.name // empty' "$GITHUB_EVENT_PATH" | grep -Fxq "$SKIP_LABEL"; then
echo "The skip label \"$SKIP_LABEL\" is set"
exit 0
fi

changed_files="$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename')"

if grep -Eq '^\.changeset/[^/]+\.md$' <<<"$changed_files"; then
echo 'The ".changeset/*.md" file pattern matched the changed files of the pull request'
exit 0
fi

failure_message="No changeset found. If these changes should not result in a new version, apply the \"$SKIP_LABEL\" label to this pull request. If these changes should result in a version bump, please add a changeset https://git.io/J6QvQ"
echo "::error::$failure_message"
exit 1
Loading