如何用GitHub Actions自动构建并发布一个静态页面。How to build and publish a static web page with GitHub Actions
- create a file
/.github/workflows/deploy_gh_pages.yml
, with following content - add vite config entry
base: /${githubRepoName}/
, note leading and trailing slashes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
name: deploy_gh_pages
on:
push:
branches: ["main", "master"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- run: |
npm install
npm run build
- uses: peaceiris/actions-gh-pages@v4
with:
github_token: $
publish_dir: ./dist
本文由作者按照 CC BY 4.0 进行授权