Skip to content

Commit 3cd015d

Browse files
author
chufan
committed
chore: update yaml
1 parent c6c7e25 commit 3cd015d

File tree

3 files changed

+167
-47
lines changed

3 files changed

+167
-47
lines changed

.github/workflows/CD.yaml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
## CD交付流水线
2+
## - 部署到Github Pages
3+
## - 部署到Vercel托管平台
4+
## - 发布新的Github Release
5+
## 参考资料:https://v2.vuepress.vuejs.org/zh/guide/deployment.html#github-pages
6+
7+
name: CD
8+
on:
9+
push:
10+
branches:
11+
- master
12+
- next
13+
workflow_dispatch:
14+
15+
16+
## vercel 环境变量
17+
env:
18+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
19+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
20+
21+
jobs:
22+
install-init:
23+
name: "依赖安装初始化"
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout Code
28+
uses: actions/checkout@v3
29+
with:
30+
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
31+
fetch-depth: 0
32+
33+
- name: Install Node.js
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 16.20.2
37+
38+
- name: PNPM Install
39+
uses: pnpm/action-setup@v2
40+
with:
41+
version: 7
42+
run_install: true
43+
44+
- name: Cache Dependencies
45+
uses: actions/cache@v3
46+
with:
47+
path: |
48+
node_modules
49+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
50+
51+
## 部署到Github-Pages
52+
deploy-github:
53+
name: "部署到Github-Pages"
54+
needs: install-init
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- name: Checkout Code
59+
uses: actions/checkout@v3
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Restore Dependencies From cache
64+
uses: actions/cache@v3
65+
with:
66+
path: |
67+
node_modules
68+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
69+
70+
71+
# 运行构建脚本
72+
- name: Build VuePress Site
73+
run: ./scripts/bundle build_proxy
74+
75+
- name: Deploy To GitHub Page
76+
uses: crazy-max/ghaction-github-pages@v3
77+
with:
78+
target_branch: pages/github
79+
build_dir: docs/.vuepress/dist
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
83+
## 部署到vercel平台
84+
# deploy-vercel:
85+
# name: "部署到Vercel平台"
86+
# needs: install-init
87+
# runs-on: ubuntu-latest
88+
# if: github.repository == '142vip/JavaScriptCollection'
89+
# steps:
90+
# - name: Checkout Code
91+
# uses: actions/checkout@v3
92+
# with:
93+
# fetch-depth: 0
94+
#
95+
# - name: Restore Dependencies From Cache
96+
# uses: actions/cache@v3
97+
# with:
98+
# path: |
99+
# node_modules
100+
# key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
101+
#
102+
# - name: Pull Vercel Environment Information
103+
# run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
104+
#
105+
# ## 注意:安装pnpm
106+
# - name: Build Project Artifacts
107+
# run: npm i pnpm@7 -g && vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
108+
#
109+
# - name: Deploy Project Artifacts to Vercel
110+
# run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
111+
112+
## 版本发布
113+
release:
114+
name: "创建Github发布"
115+
runs-on: ubuntu-latest
116+
needs: install-init
117+
## 主库master、next且执行release更新时执行
118+
if: github.repository == '142vip/JavaScriptCollection' && startsWith(github.event.head_commit.message, 'chore(release):')
119+
120+
steps:
121+
- name: Restore Dependencies From cache
122+
uses: actions/cache@v3
123+
with:
124+
path: |
125+
~/.pnpm-store
126+
node_modules
127+
key: ${{ runner.os }}-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
128+
restore-keys: |
129+
${{ runner.os }}-cache-
130+
131+
### 打成压缩包
132+
- name: Create Zip Package
133+
run: |
134+
zip -r JavaScriptCollection.zip . \
135+
-x "node_modules/*"
136+
137+
# 提取版本号
138+
- name: Get New Version Number
139+
id: extract_version
140+
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
141+
142+
# 创建发布版本
143+
- name: Create New Release
144+
id: create_release
145+
uses: actions/create-release@latest
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
with:
149+
tag_name: v${{ steps.extract_version.outputs.version }}
150+
release_name: v${{ steps.extract_version.outputs.version }}
151+
body: |
152+
Release ${{ steps.extract_version.outputs.version }}
153+
154+
### Features
155+
156+
### Bug Fixes
157+
158+
## 更新资源
159+
- name: Upload Resource Assets
160+
uses: actions/upload-release-asset@latest
161+
env:
162+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
with:
164+
upload_url: ${{ steps.create_release.outputs.upload_url }}
165+
asset_path: ./JavaScriptCollection.zip
166+
asset_name: JavaScriptCollection.zip
167+
asset_content_type: application/zip

.github/workflows/gh-deploy.yml

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

Readme.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
## JavaScriptCollection
2-
3-
41
### 在线浏览
52

63
- 尝鲜版:<https://142vip.github.io/JavaScriptCollection>

0 commit comments

Comments
 (0)