Skip to content

Commit

Permalink
Merge pull request #3073 from NomicFoundation/add-changeset-check
Browse files Browse the repository at this point in the history
Add changeset check
  • Loading branch information
fvictorio committed Jan 9, 2023
2 parents 3845c0b + fa01700 commit 2e1d0db
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/check-changeset-added.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Fails if a PR doesn't have a changeset and is not labeled
# as "no changeset needed"

name: Check that the PR has a changeset

on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled

jobs:
check-if-changeset:
name: Check that PR has a changeset
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const pullNumber = context.issue.number;
const { data: files } = await github.rest.pulls.listFiles({
...context.issue,
pull_number: pullNumber
});
const changeset = files.find(
file => file.status === "added" && file.filename.startsWith(".changeset/")
);
if (changeset !== undefined) {
console.log("Changeset found:", changeset.filename);
return;
}
console.log("No changeset found");
const { data: pull } = await github.rest.pulls.get({
...context.issue,
pull_number: pullNumber
});
const noChangesetNeededLabel = pull.labels
.some(l => l.name === "no changeset needed");
if (noChangesetNeededLabel) {
console.log('The PR is labeled as "no changeset needed"');
return;
}
console.log('The PR is not labeled as "no changeset needed"');
process.exit(1);

0 comments on commit 2e1d0db

Please sign in to comment.