Skip to content

Commit 138b475

Browse files
committed
feat(ci): 添加新的部署工作流以支持文档和示例项目的自动化部署
1 parent 4b9c73d commit 138b475

File tree

2 files changed

+98
-48
lines changed

2 files changed

+98
-48
lines changed

.github/workflows/deploy.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Deploy Element UI X
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- 'docs/**'
8+
- 'examples/**'
9+
pull_request:
10+
branches: [master]
11+
paths:
12+
- 'docs/**'
13+
- 'examples/**'
14+
workflow_dispatch:
15+
inputs:
16+
deploy_target:
17+
description: '部署目标'
18+
required: true
19+
default: 'all'
20+
type: choice
21+
options:
22+
- all
23+
- docs
24+
- examples
25+
26+
jobs:
27+
deploy-docs:
28+
name: 部署文档站
29+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.deploy_target == 'all' || github.event.inputs.deploy_target == 'docs' }}
30+
runs-on: ubuntu-latest
31+
defaults:
32+
run:
33+
working-directory: docs
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
38+
39+
- name: Configure Git
40+
run: |
41+
git config --global user.name "GitHub Actions"
42+
git config --global user.email "github-actions@github.com"
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v3
46+
with:
47+
node-version: '16'
48+
cache: 'npm'
49+
cache-dependency-path: docs/package-lock.json
50+
51+
- name: Install dependencies
52+
run: npm ci
53+
54+
- name: Build documentation
55+
run: npm run build
56+
57+
- name: Deploy to Vercel
58+
uses: amondnet/vercel-action@v20
59+
with:
60+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
61+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
62+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_DOCS }}
63+
working-directory: docs
64+
vercel-args: ${{ github.event_name == 'push' && '--prod' || '' }}
65+
66+
deploy-examples:
67+
name: 部署示例项目
68+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.deploy_target == 'all' || github.event.inputs.deploy_target == 'examples' }}
69+
runs-on: ubuntu-latest
70+
defaults:
71+
run:
72+
working-directory: examples
73+
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v3
77+
78+
- name: Setup Node.js
79+
uses: actions/setup-node@v3
80+
with:
81+
node-version: '16'
82+
cache: 'npm'
83+
cache-dependency-path: examples/package-lock.json
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Build
89+
run: npm run build
90+
91+
- name: Deploy to Vercel
92+
uses: amondnet/vercel-action@v20
93+
with:
94+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
95+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
96+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_EXAMPLES }}
97+
working-directory: examples
98+
vercel-args: '--prod'

docs/.github/workflows/deploy.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)