Skip to content

Commit af58e36

Browse files
committed
Update workflow to build then in separte jobs, publish and deploy
1 parent 8b9353a commit af58e36

1 file changed

Lines changed: 48 additions & 13 deletions

File tree

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,67 @@
11
name: Build and Deploy
22
on:
33
push:
4-
tags:
5-
- v*
6-
permissions:
7-
contents: write
8-
id-token: write
4+
permissions: {}
95
jobs:
10-
build-and-deploy:
6+
build:
117
runs-on: ubuntu-latest
12-
environment: deploy
138
steps:
14-
- name: Checkout 🛎️
9+
- name: Checkout
1510
uses: actions/checkout@v4
1611

17-
- name: Use Node.js 😂
12+
- name: Use Node.js
1813
uses: actions/setup-node@v4
1914
with:
2015
node-version: 24
21-
registry-url: 'https://registry.npmjs.org'
2216

23-
- name: Install and Build 🔧
17+
- name: Install and Build
2418
run: |
2519
npm ci
2620
npm run build-ci
27-
npm publish
2821
29-
- name: Deploy 🚀
22+
- name: Upload build artifacts
23+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: build
27+
path: .
28+
29+
publish:
30+
needs: build
31+
if: startsWith(github.ref, 'refs/tags/v')
32+
runs-on: ubuntu-latest
33+
environment: deploy
34+
permissions:
35+
id-token: write
36+
steps:
37+
- name: Download build artifacts
38+
uses: actions/download-artifact@v4
39+
with:
40+
name: build
41+
42+
- name: Use Node.js
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: 24
46+
registry-url: 'https://registry.npmjs.org'
47+
48+
- name: Publish to npm
49+
run: npm publish
50+
51+
deploy:
52+
needs: build
53+
if: github.ref == 'refs/heads/main'
54+
runs-on: ubuntu-latest
55+
environment: deploy
56+
permissions:
57+
contents: write
58+
steps:
59+
- name: Download build artifacts
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: build
63+
64+
- name: Deploy to GitHub Pages
3065
uses: JamesIves/github-pages-deploy-action@v4
3166
with:
3267
folder: .

0 commit comments

Comments
 (0)