Skip to content

Commit 7453077

Browse files
Copilotjoshblack
andauthored
ci: update check for changeset workflow with local bash script (#8084)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com> Co-authored-by: Josh Black <joshblack@github.com>
1 parent be2950f commit 7453077

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

.github/workflows/check_for_changeset.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,30 @@ jobs:
1515
check-for-changeset:
1616
name: Check for changeset
1717
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
pull-requests: read
1821
steps:
19-
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
2022
- name: 'Check for changeset'
21-
uses: brettcannon/check-for-changed-files@v1
22-
with:
23-
file-pattern: '.changeset/*.md'
24-
skip-label: 'skip changeset'
25-
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'
23+
env:
24+
GH_TOKEN: ${{ github.token }}
25+
PR_NUMBER: ${{ github.event.pull_request.number }}
26+
SKIP_LABEL: 'skip changeset'
27+
run: |
28+
set -euo pipefail
29+
30+
if jq -r '.pull_request.labels[]?.name // empty' "$GITHUB_EVENT_PATH" | grep -Fxq "$SKIP_LABEL"; then
31+
echo "The skip label \"$SKIP_LABEL\" is set"
32+
exit 0
33+
fi
34+
35+
changed_files="$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename')"
36+
37+
if grep -Eq '^\.changeset/[^/]+\.md$' <<<"$changed_files"; then
38+
echo 'The ".changeset/*.md" file pattern matched the changed files of the pull request'
39+
exit 0
40+
fi
41+
42+
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"
43+
echo "::error::$failure_message"
44+
exit 1

0 commit comments

Comments
 (0)