Repository navigation
108 lines (97 loc) · 3.58 KB
/
Copy pathnode.js.yml
File metadata and controls
108 lines (97 loc) · 3.58 KB
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
103
104
105
106
107
108
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# package-lock.json 中的 git 依赖以 git+ssh:// 形式记录,统一改写为 HTTPS,
# 保证依赖克隆不依赖 runner 的 SSH 配置(bun install 对这些 git 依赖安装不完整)。
- name: Use HTTPS for git dependencies
run: git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
- name: Install dependencies
run: npm ci --no-audit --no-fund --loglevel verbose
- run: npm run build
- name: Build docs
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/develop')
run: npm run docs
# We expect to see syntax errors from the old jsdoc cli not understanding some of our syntax
# It will still generate what it can, so it's safe to ignore the error
continue-on-error: true
- name: Upload dist
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/develop')
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
if-no-files-found: error
- name: Upload pages artifact
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/develop')
uses: actions/upload-pages-artifact@v3
with:
path: ./playground/
deploy:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/develop')
concurrency:
group: "deploy"
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: write
pages: write
id-token: write
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout (with push access)
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Deploy to develop-builds branch (npm package)
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Backup dist
rm -rf /tmp/dist
cp -r dist /tmp/dist
# Fetch all branches
git fetch origin
# Checkout or create develop-builds based on develop
if git show-ref --verify --quiet refs/remotes/origin/develop-builds; then
git checkout develop-builds
else
git checkout -b develop-builds origin/develop
fi
# Make develop-builds exactly mirror develop (removes old playground layout)
git reset --hard origin/develop
# Replace dist with built artifacts
rm -rf dist
mkdir dist
cp -r /tmp/dist/* dist/
# Force add dist (ignore .gitignore)
git add -f dist
# Commit if changed
git commit -m "chore: update dist from develop" || echo "No changes"
# Push
git push --force origin develop-builds
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4