Skip to content

Commit 4f3e4ca

Browse files
committed
feat(setup-project): enhance action with build step and update workflow references
* Added `build` input to the setup project action to control project building. * Updated `check-dist.yml` to utilize the new build functionality. * Refactored `licensed.yml` to replace Node.js setup with the new setup project action.
1 parent be80228 commit 4f3e4ca

3 files changed

Lines changed: 32 additions & 56 deletions

File tree

.github/actions/setup-project/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ inputs:
55
node-version:
66
description: Node.js version to use
77
required: false
8-
default: '20'
8+
99
pnpm-version:
1010
description: pnpm version to use
1111
required: false
12+
1213
registry-url:
1314
description: npm registry URL
1415
required: false
1516

17+
build:
18+
description: Whether to build the project
19+
required: false
20+
default: 'false'
21+
22+
1623
runs:
1724
using: composite
1825
steps:
@@ -31,3 +38,8 @@ runs:
3138
- name: Install dependencies
3239
run: pnpm install
3340
shell: bash
41+
42+
- name: Build project
43+
if: ${{ inputs.build == 'true' }}
44+
run: pnpm run build
45+
shell: bash

.github/workflows/check-dist.yml

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# In JavaScript actions, `dist/` is a special directory. When you reference
2-
# an action with the `uses:` property, `dist/index.js` is the code that will be
3-
# run. For this project, the `dist/index.js` file is transpiled from other
4-
# source files. This workflow ensures the `dist/` directory contains the
5-
# expected transpiled code.
6-
#
7-
# If this workflow is run from a feature branch, it will act as an additional CI
8-
# check and fail if the checked-in `dist/` directory does not match what is
9-
# expected from the build.
101
name: Check Transpiled JavaScript
112

123
on:
@@ -22,55 +13,36 @@ permissions:
2213

2314
jobs:
2415
check-dist:
25-
name: Check dist/
16+
name: Check dist/index.js
2617
runs-on: ubuntu-latest
27-
2818
steps:
29-
# Checkout the repository.
3019
- name: Checkout
31-
id: checkout
3220
uses: actions/checkout@v4
3321

34-
# Setup Node.js using the version specified in `.node-version`.
35-
- name: Setup Node.js
36-
id: setup-node
37-
uses: actions/setup-node@v4
22+
- name: Setup project
23+
uses: ./.github/actions/setup-project
3824
with:
39-
node-version-file: .node-version
40-
cache: npm
41-
42-
# Install dependencies using `npm ci`.
43-
- name: Install Dependencies
44-
id: install
45-
run: npm ci
46-
47-
# Build the `dist/` directory.
48-
- name: Build dist/ Directory
49-
id: build
50-
run: npm run bundle
25+
build: 'true'
5126

52-
# This will fail the workflow if the `dist/` directory is different than
53-
# expected.
54-
- name: Compare Directories
55-
id: diff
27+
- name: Check if dist/index.js exists
5628
run: |
57-
if [ ! -d dist/ ]; then
58-
echo "Expected dist/ directory does not exist. See status below:"
59-
ls -la ./
29+
if [ ! -f actions/codeql-analyzer /dist/index.js ]; then
30+
echo "Expected dist/index.js does not exist. See status below:"
31+
ls -la actions/codeql-analyzer /dist/
6032
exit 1
6133
fi
62-
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
63-
echo "Detected uncommitted changes after build. See status below:"
64-
git diff --ignore-space-at-eol --text dist/
34+
35+
- name: Compare dist/index.js
36+
run: |
37+
if [ "$(git diff --ignore-space-at-eol --text actions/codeql-analyzer /dist/index.js | wc -l)" -gt "0" ]; then
38+
echo "Detected uncommitted changes in dist/index.js after build. See diff below:"
39+
git diff --ignore-space-at-eol --text actions/codeql-analyzer /dist/index.js
6540
exit 1
6641
fi
6742
68-
# If `dist/` was different than expected, upload the expected version as a
69-
# workflow artifact.
70-
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
43+
- if: ${{ failure() }}
7144
name: Upload Artifact
72-
id: upload
7345
uses: actions/upload-artifact@v4
7446
with:
75-
name: dist
76-
path: dist/
47+
name: codeql-analyzer -dist
48+
path: actions/codeql-analyzer /dist/

.github/workflows/licensed.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ jobs:
2929
id: checkout
3030
uses: actions/checkout@v4
3131

32-
- name: Setup Node.js
33-
id: setup-node
34-
uses: actions/setup-node@v4
35-
with:
36-
node-version-file: .node-version
37-
cache: npm
38-
39-
- name: Install Dependencies
40-
id: npm-ci
41-
run: npm ci
32+
- name: Setup project
33+
uses: ./.github/actions/setup-project
4234

4335
- name: Setup Ruby
4436
id: setup-ruby

0 commit comments

Comments
 (0)