Skip to content

Commit a49725c

Browse files
authored
Update node.js.yml
1 parent 8d532bc commit a49725c

File tree

1 file changed

+53
-20
lines changed

1 file changed

+53
-20
lines changed

.github/workflows/node.js.yml

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,64 @@
1-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
1+
# .github/workflows/ci.yml
32

4-
name: Node.js CI
3+
# Name of the workflow, displayed in the "Actions" tab on GitHub.
4+
name: Frontend CI
55

6+
# --- Triggers ---
7+
# Defines when the workflow will run.
68
on:
9+
# Run on every push to any branch.
710
push:
8-
branches: [ "main" ]
11+
branches: [ "**" ]
12+
13+
# Also run on pull requests targeting the 'main' branch.
914
pull_request:
1015
branches: [ "main" ]
1116

12-
jobs:
13-
build:
17+
# Allows manual triggering from the GitHub Actions UI.
18+
workflow_dispatch:
1419

20+
# --- Jobs ---
21+
# A workflow is made up of one or more jobs.
22+
jobs:
23+
# The single job in this workflow is named "build-and-test".
24+
build-and-test:
25+
# The type of virtual machine to run the job on.
1526
runs-on: ubuntu-latest
1627

17-
strategy:
18-
matrix:
19-
node-version: [18.x, 20.x, 22.x]
20-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21-
28+
# A job is a sequence of steps.
2229
steps:
23-
- uses: actions/checkout@v4
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
cache: 'npm'
29-
- run: npm ci
30-
- run: npm run build --if-present
31-
- run: npm test
30+
# --- 1. Checkout Code ---
31+
# Checks out your repository's code so the workflow can access it.
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
# --- 2. Setup Node.js Environment ---
36+
# Installs a specific version of Node.js on the runner.
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '22' # Using a specific major version is recommended.
41+
# Automatically cache npm dependencies for faster builds.
42+
cache: 'npm'
43+
44+
# --- 3. Install Dependencies ---
45+
# Runs "npm install" to install all packages from package.json and package-lock.json.
46+
- name: Install dependencies
47+
run: npm ci # 'npm ci' is often faster and more reliable for CI environments than 'npm install'.
48+
49+
# --- 4. Run Linter ---
50+
# Executes the "lint" script defined in your package.json to check for code quality.
51+
- name: Run linter
52+
run: npm run lint
53+
54+
# --- 5. Run Tests ---
55+
# Executes the "test" script defined in your package.json.
56+
# This runs your Vitest suite and will fail the workflow if any tests fail.
57+
- name: Run tests
58+
run: npm run test
59+
60+
# --- 6. Build for Production ---
61+
# Executes the "build" script. This is a crucial step to ensure that the
62+
# application is actually buildable and ready for deployment.
63+
- name: Build application
64+
run: npm run build

0 commit comments

Comments
 (0)