From 6f8f998bdd8923f1e0295c782930c36d56348028 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Tue, 29 Apr 2025 22:09:26 +0200 Subject: [PATCH 1/4] Add workflow to check that dist has been updated --- .github/workflows/check-dist.yml | 59 ++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/check-dist.yml diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml new file mode 100644 index 0000000..ecdd6bc --- /dev/null +++ b/.github/workflows/check-dist.yml @@ -0,0 +1,59 @@ +# In TypeScript actions, `dist/` is a special directory. When you reference +# an action with the `uses:` property, `dist/index.js` is the code that will be +# run. For this project, the `dist/index.js` file is transpiled from other +# source files. This workflow ensures the `dist/` directory contains the +# expected transpiled code. +# +# If this workflow is run from a feature branch, it will act as an additional CI +# check and fail if the checked-in `dist/` directory does not match what is +# expected from the build. +name: Check Transpiled JavaScript + +on: + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + check-dist: + name: Check dist/ + runs-on: ubuntu-latest + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: npm + + - name: Install Dependencies + id: install + run: npm ci + + - name: Build dist/ Directory + id: build + run: npm run bundle + + # This will fail the workflow if the `dist/` directory is different than + # expected. + - name: Compare Directories + id: diff + run: | + if [ ! -d dist/ ]; then + echo "Expected dist/ directory does not exist. See status below:" + ls -la ./ + exit 1 + fi + if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff --ignore-space-at-eol --text dist/ + exit 1 + fi diff --git a/package.json b/package.json index 534b7a6..f5f09a3 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "node": ">=20" }, "scripts": { + "bundle": "npm run format:write && npm run package", "format:write": "npx prettier --write .", "format:check": "npx prettier --check .", "lint": "npx eslint .", From e77f86bf280794ec22ab7643e8b4f968e910d8ed Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Tue, 29 Apr 2025 22:09:44 +0200 Subject: [PATCH 2/4] Introduce diff to test workflow --- src/commentManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commentManager.ts b/src/commentManager.ts index 69f97a5..bf811dc 100644 --- a/src/commentManager.ts +++ b/src/commentManager.ts @@ -6,7 +6,7 @@ export function previousCommentFor(workflowName: string) { body?: string }) => { return ( - comment.user?.login === 'github-actions[bot]' && + comment.user?.login === 'github-actions[botzzz]' && comment.user?.type === 'Bot' && comment.body?.startsWith(`🕒 Workflow "${workflowName}"`) ) From 9807f2de808fb9706aa1f070f5d3b3e66163ca65 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Tue, 29 Apr 2025 22:12:03 +0200 Subject: [PATCH 3/4] Remove changes to fix workflow --- .github/workflows/check-dist.yml | 2 +- src/commentManager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index ecdd6bc..933b7c2 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -7,7 +7,7 @@ # If this workflow is run from a feature branch, it will act as an additional CI # check and fail if the checked-in `dist/` directory does not match what is # expected from the build. -name: Check Transpiled JavaScript +name: check-dist on: pull_request: diff --git a/src/commentManager.ts b/src/commentManager.ts index bf811dc..69f97a5 100644 --- a/src/commentManager.ts +++ b/src/commentManager.ts @@ -6,7 +6,7 @@ export function previousCommentFor(workflowName: string) { body?: string }) => { return ( - comment.user?.login === 'github-actions[botzzz]' && + comment.user?.login === 'github-actions[bot]' && comment.user?.type === 'Bot' && comment.body?.startsWith(`🕒 Workflow "${workflowName}"`) ) From 387fd8afed38bb4f7e0ae96b18528b104fd79299 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Tue, 29 Apr 2025 22:12:37 +0200 Subject: [PATCH 4/4] remove job name --- .github/workflows/check-dist.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 933b7c2..46cf42f 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -19,7 +19,6 @@ permissions: jobs: check-dist: - name: Check dist/ runs-on: ubuntu-latest steps: