-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (79 loc) · 2.96 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: 🚀 Test & Deploy Static Content to GitHub Pages
on: push
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read # Read access to repository contents
pages: write # Write access for deployment to GitHub Pages
id-token: write # Allow GitHub to issue an ID token for authentication
# Allow only one concurrent deployment at a time
concurrency:
group: 'pages' # Group deployments by name for concurrency control
cancel-in-progress: true # Cancel any in-progress deployments if a new one starts
jobs:
# Setup environment and dependencies
setup:
name: 🛠️ Setup Development Environment
runs-on: ubuntu-latest
outputs:
node-modules-path: ${{ steps.cache-dependencies.outputs.cache-hit }}
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
- name: Cache Dependencies 📦
uses: actions/cache@v4
id: cache-dependencies
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Node.js Environment ⚙️
uses: ./.github/actions/setup
with:
node-version: 20
- name: Install Dependencies 🛠️
run: yarn install --immutable
if: steps.cache-dependencies.outputs.cache-hit != 'true' # Only install if cache miss
tests:
name: 🔍 Execute Unit Tests
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
- name: Setup Node.js Environment ⚙️
uses: ./.github/actions/setup
with:
node-version: 20
- name: Install Dependencies 🛠️
run: yarn install --immutable
- name: Run Tests 🧪
run: yarn test
deploy:
name: 🚀 Deploy to GitHub Pages
needs: [setup, tests]
if: github.ref == 'refs/heads/main' # Only deploy from the main branch
environment:
name: github-pages # Set deployment environment to GitHub Pages
url: ${{ steps.deployment.outputs.page_url }} # Output page URL
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
- name: Setup Node.js Environment ⚙️
uses: ./.github/actions/setup
with:
node-version: 20
- name: Install Dependencies 🛠️
run: yarn install --immutable
- name: Build Static Content 🏗️
run: yarn build:demo # Build the static site with Vite
- name: Setup GitHub Pages ⚙️
uses: actions/configure-pages@v4
- name: Upload Build Artifacts 📦
uses: actions/upload-pages-artifact@v3
with:
path: './dist' # Path to the build output directory
- name: Deploy to GitHub Pages 🌐
id: deployment
uses: actions/deploy-pages@v4 # Deploy the build to GitHub Pages