forked from selwynpolit/d9book
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (81 loc) · 2.26 KB
/
ci-cd.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
name: CI/CD
on:
push:
branches:
- gh-pages
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
pages: write
contents: read
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
cleanup:
name: 🧹 Clean up GitHub repository
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: 🗑 Delete deployment
uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: github-pages
onlyRemoveDeployments: true
- name: 🗑 Delete workflow runs
uses: dmvict/clean-workflow-runs@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
save_period: 30
save_min_runs_number: 0
build:
name: 🏗️ Build (node - ${{ matrix.node }})
needs: cleanup
runs-on: ubuntu-latest
strategy:
matrix:
node: [18.x, 20.x, 21.x]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ⚙️ Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: ⚙️ Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
timeout-minutes: 5
with:
cache: pnpm
node-version: ${{ matrix.node }}
- name: ⚙️ Setup Pages
uses: actions/configure-pages@v4
- name: 📦 Install dependencies
env:
PNPM_FLAGS: --frozen-lockfile --color=always
run: pnpm i ${{ env.PNPM_FLAGS }}
- name: 🏗️ Build site with VitePress
run: pnpm book:build
- name: 📤 Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
name: github-pages-dist-${{ matrix.node }}
deploy:
name: 🌐 Deploy
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: 🚀 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: github-pages-dist-18.x