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
41 changes: 23 additions & 18 deletions .github/workflows/check-changeset.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check Changeset

on:
pull_request:
pull_request_target:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
Expand Down Expand Up @@ -32,26 +32,31 @@ jobs:
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- uses: actions/checkout@v4
if: steps.check-label.outputs.skip != 'true'
with:
fetch-depth: 0

- name: Check for changeset
id: check
if: steps.check-label.outputs.skip != 'true'
run: |
CHANGED=$(git diff --name-only origin/main...HEAD | grep "^.changeset/.*\.md$" || true)

if [ -z "$CHANGED" ]; then
echo "found=false" >> "$GITHUB_OUTPUT"
echo "❌ No changeset found. Run 'npx changeset' locally to create one for your changes."
exit 1
else
echo "found=true" >> "$GITHUB_OUTPUT"
echo "✅ Changeset detected:"
echo "$CHANGED"
fi
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const pull_number = context.issue.number;

// Fetch list of files changed in the PR
const files = await github.paginate(github.rest.pulls.listFiles, {
owner,
repo,
pull_number
});

const changesetFiles = files.filter(f => f.filename.startsWith('.changeset/') && f.filename.endsWith('.md'));

if (changesetFiles.length === 0) {
core.setOutput('found', 'false');
core.setFailed("❌ No changeset found. Run 'npx changeset' locally to create one for your changes.");
} else {
core.setOutput('found', 'true');
console.log('✅ Changeset detected:\n' + changesetFiles.map(f => f.filename).join('\n'));
}

- name: Comment on PR if missing
if: failure() && steps.check.outputs.found == 'false'
Expand Down
Loading