Skip to content

Commit 5b07d80

Browse files
author
igyfhc
committed
learn
1 parent b6f0057 commit 5b07d80

File tree

2 files changed

+83
-5
lines changed

2 files changed

+83
-5
lines changed

.apps/blog/docs/.vitepress/config.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { defineConfig } from 'vitepress';
44
export default defineConfig({
55
outDir: '../../../.deploy/blog',
66
base: '/blog/',
7-
title: 'My Awesome Project',
8-
description: 'A VitePress Site',
7+
title: '博客 Blog',
8+
description: 'Vitepress generate. Github actions deploy',
99
locales: {
1010
root: {
1111
lang: 'zh',
@@ -20,10 +20,11 @@ export default defineConfig({
2020

2121
sidebar: [
2222
{
23-
text: 'Examples',
23+
text: '示例',
2424
items: [
25-
{text: 'Markdown Examples', link: '/markdown-examples'},
26-
{text: 'Runtime API Examples', link: '/api-examples'},
25+
{text: 'Markdown 示例', link: '/markdown-examples'},
26+
{text: '运行时 API 示例', link: '/api-examples'},
27+
{text: '学习使用Github actions', link: '/learn-github-actions'},
2728
],
2829
},
2930
],
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## 学习使用 Github actions 自动部署静态网页。
2+
3+
`.github/workflows`目录下定义`.yml`文件,即可自动执行逻辑。写本文的时候,已经测试可以。
4+
5+
定义如下:
6+
7+
`build-blog.yml`:
8+
9+
```yaml
10+
name: Build blog
11+
12+
on:
13+
workflow_call:
14+
15+
defaults:
16+
run:
17+
working-directory: .apps/blog
18+
19+
jobs:
20+
build:
21+
name: Build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
- name: Setup Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: latest
32+
- name: Setup Pages
33+
uses: actions/configure-pages@v4
34+
- name: Install dependencies
35+
run: npm ci # ci: Clean install a project
36+
- name: Build with VitePress
37+
run: npm run docs:build
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v3
40+
with:
41+
path: .deploy
42+
43+
```
44+
45+
`deploy.yml`
46+
47+
```yaml
48+
name: Deploy
49+
50+
on:
51+
push:
52+
branches: [master]
53+
54+
concurrency:
55+
group: pages
56+
cancel-in-progress: false
57+
58+
permissions:
59+
contents: read
60+
pages: write
61+
id-token: write
62+
63+
jobs:
64+
call-build-blog:
65+
uses: ./.github/workflows/build-blog.yml
66+
deploy:
67+
needs: call-build-blog
68+
environment:
69+
name: github-pages
70+
runs-on: ubuntu-latest
71+
name: Deploy
72+
steps:
73+
- name: Deploy to GitHub Pages
74+
id: deployment
75+
uses: actions/deploy-pages@v4
76+
77+
```

0 commit comments

Comments
 (0)