Skip to content

Commit f49c8a5

Browse files
Add GitHub Actions workflow for Node.js CI and deployment
This workflow automates the CI process for Node.js applications, including build and deployment to GitHub Pages.
1 parent a6428b1 commit f49c8a5

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This is a basic workflow to help you get started with Actions
2+
name: Node.js CI + Deploy + 2
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["main"]
9+
10+
# Need permissions for GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
node-version: [20.x]
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: 'npm'
31+
- run: npm install
32+
- run: npm run build --if-present
33+
34+
- name: Upload artifact
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: './dist' # ← change to your build output folder (dist, build, out, etc.)
38+
39+
deploy:
40+
needs: build
41+
runs-on: ubuntu-latest
42+
if: github.ref == 'refs/heads/main' # Only deploy on push to main, not PRs
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deployment.outputs.page_url }}
46+
steps:
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)