Skip to content

Commit 4d1213b

Browse files
authored
Merge pull request #140 from SableClient/fix/ci-changeset-comment-and-preview-path-filters
fix(ci): remove changeset comment after adding changeset and add cloudflare worker preview path filters
2 parents 9a67295 + eba8a03 commit 4d1213b

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

.github/workflows/cloudflare-web-preview.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Cloudflare Worker Preview Deploy
22

33
on:
44
pull_request:
5+
paths:
6+
- 'src/**'
7+
- 'index.html'
8+
- 'package.json'
9+
- 'package-lock.json'
10+
- 'vite.config.ts'
11+
- 'tsconfig.json'
12+
- '.github/workflows/cloudflare-web-preview.yml'
13+
- '.github/actions/setup/**'
514

615
concurrency:
716
group: cloudflare-worker-preview-${{ github.event.pull_request.number }}

.github/workflows/require-changeset.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,38 @@ jobs:
4949
fi
5050
5151
- name: Manage changeset comment
52-
if: steps.labels.outputs.skip == 'false'
5352
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
5453
env:
54+
SKIP: ${{ steps.labels.outputs.skip }}
5555
CHANGESET_FOUND: ${{ steps.check.outputs.found }}
5656
with:
5757
github-token: ${{ secrets.GITHUB_TOKEN }}
5858
script: |
5959
const marker = '<!-- require-changeset -->';
60+
const skip = process.env.SKIP === 'true';
6061
const found = process.env.CHANGESET_FOUND === 'true';
6162
const { owner, repo } = context.repo;
6263
const issue_number = context.issue.number;
6364
64-
// Always delete the old comment first so the new one appears fresh after each commit
6565
const comments = await github.paginate(github.rest.issues.listComments, {
6666
owner, repo, issue_number,
6767
});
6868
const existing = comments.find(
6969
(c) => c.user.type === 'Bot' && c.body.includes(marker),
7070
);
71-
if (existing) {
72-
await github.rest.issues.deleteComment({
73-
owner, repo, comment_id: existing.id,
74-
});
71+
72+
if (skip || found) {
73+
// Clean up the warning comment — changeset added or PR marked internal
74+
if (existing) {
75+
await github.rest.issues.deleteComment({
76+
owner, repo, comment_id: existing.id,
77+
});
78+
}
79+
return;
7580
}
7681
77-
if (!found) {
78-
const body = `${marker}
79-
### ⚠️ Missing changeset
82+
const body = `${marker}
83+
## ⚠️ Missing changeset
8084
8185
This pull request does not include a changeset. Please add one before requesting review so the change is properly documented and included in the release notes.
8286
@@ -99,6 +103,10 @@ jobs:
99103
100104
> If this PR is internal/maintenance with no user-facing impact, a maintainer can add the \`internal\` label to skip this check.`;
101105
102-
await github.rest.issues.createComment({ owner, repo, issue_number, body });
103-
core.setFailed('No changeset found. Add a changeset file or apply the "internal" label to skip.');
106+
if (existing) {
107+
await github.rest.issues.deleteComment({
108+
owner, repo, comment_id: existing.id,
109+
});
104110
}
111+
await github.rest.issues.createComment({ owner, repo, issue_number, body });
112+
core.setFailed('No changeset found. Add a changeset file or apply the "internal" label to skip.');

0 commit comments

Comments
 (0)