Skip to content

Commit d07fdb1

Browse files
committed
feat: check for changesets
Check if a changeset is needed and if so, leave a comment on the PR - Add a "changeset" script to add a changeset - Add a "changeset:status" script to check if a changeset is needed - Rename "publish:changeset" to "chanageset:publish" to align with the other commands
1 parent 723f772 commit d07fdb1

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

.github/workflows/changeset.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Changeset check
2+
3+
on: pull_request
4+
5+
jobs:
6+
changeset-check:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Create GitHub App Token
10+
id: app-token
11+
uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # 1.11.6
12+
with:
13+
app-id: ${{ vars.NL_DESIGN_SYSTEM_BOT_APP_ID }}
14+
private-key: ${{ secrets.NL_DESIGN_SYSTEM_BOT_PRIVATE_KEY }}
15+
16+
- name: Checkout
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install pnpm package manager
22+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
23+
24+
- name: Install dependencies
25+
run: pnpm install --frozen-lockfile
26+
27+
- name: Changset status
28+
id: changeset-status
29+
run: |
30+
if pnpm run changeset:status; then
31+
echo "status=0" | tee -a $GITHUB_OUTPUT
32+
else
33+
echo "status=1" | tee -a $GITHUB_OUTPUT
34+
fi
35+
36+
- name: Find existing comment
37+
id: find-existing-comment
38+
env:
39+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
40+
run: |
41+
COMMENT=$(gh api repos/:owner/:repo/issues/${{ github.event.pull_request.number }}/comments --jq ".[] | select(.user.login == \"${{ steps.app-token.outputs.app-slug }}[bot]\") | .id")
42+
echo "comment=${COMMENT}" | tee -a $GITHUB_OUTPUT
43+
44+
- name: Remove existing comment
45+
if: ${{ steps.find-existing-comment.outputs.comment != '' && steps.changeset-status.outputs.status == 0 }}
46+
env:
47+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
48+
run: gh api --method DELETE repos/:owner/:repo/issues/comments/${{ steps.find-existing-comment.outputs.comment }}
49+
50+
- name: Create new comment
51+
if: ${{ steps.find-existing-comment.outputs.comment == '' && steps.changeset-status.outputs.status == 1 }}
52+
env:
53+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
54+
run: |
55+
gh pr comment ${{ github.event.pull_request.number }} --body ":warning: Deze pull request mist een changeset terwijl er wel een nodig is :warning:"
56+
57+
- name: Update existing comment
58+
if: ${{ steps.find-existing-comment.outputs.comment != '' && steps.changeset-status.outputs.status == 1 }}
59+
env:
60+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
61+
run: |
62+
gh pr comment ${{ github.event.pull_request.number }} --edit-last --body ":warning: Deze pull request mist nog steeds een changeset terwijl er wel een nodig is. :warning:"

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ jobs:
4646
commit: "docs(release): design system packages"
4747
setupGitUser: false
4848
title: "docs(release): design system packages"
49-
publish: "pnpm run publish:changeset"
49+
publish: "pnpm run changeset:publish"

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@
7171
"lint-workspaces": "pnpm --recursive --if-present run lint",
7272
"prepare": "husky",
7373
"prettier": "prettier --write .",
74-
"publish:changeset": "changeset publish",
74+
"changeset": "changeset add",
75+
"changeset:publish": "changeset publish",
76+
"changeset:status": "changeset status --since origin/main",
7577
"start": "http-server packages/storybook/dist/",
7678
"storybook": "npm-run-all --parallel watch:**",
7779
"storybook-test": "pnpm --filter @nl-design-system-candidate/storybook-test run storybook",

packages/components-react/code-block-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nl-design-system-candidate/code-block-react",
33
"version": "1.3.0",
4-
"description": "Blok met 1 of meerdere regels computercode.",
4+
"description": "Blok met 1 of meerdere regels computercode",
55
"license": "EUPL-1.2",
66
"homepage": "https://github.com/nl-design-system/candidate/tree/main/packages/components-react/code-block-react#readme",
77
"type": "module",

0 commit comments

Comments
 (0)