|
@@ -1,43 +1,32 @@
|
|
|
-# This is a basic workflow to help you get started with Actions
|
|
|
+# name 可以自定义
|
|
|
+name: Deploy GitHub Pages
|
|
|
|
|
|
-name: Build and deploy
|
|
|
-
|
|
|
-# Controls when the action will run.
|
|
|
+# 触发条件:在 push 到 main/master 分支后,新的 Github 项目 应该都是 main,而之前的项目一般都是 master
|
|
|
on:
|
|
|
- # Triggers the workflow on push or pull request events but only for the main branch
|
|
|
push:
|
|
|
- branches: [ main ]
|
|
|
-
|
|
|
- # Allows you to run this workflow manually from the Actions tab
|
|
|
- workflow_dispatch:
|
|
|
+ branches:
|
|
|
+ - main
|
|
|
|
|
|
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
|
+# 任务
|
|
|
jobs:
|
|
|
- # This workflow contains a single job called "build"
|
|
|
- build:
|
|
|
- # The type of runner that the job will run on
|
|
|
+ build-and-deploy:
|
|
|
+ # 服务器环境:最新版 Ubuntu
|
|
|
runs-on: ubuntu-latest
|
|
|
-
|
|
|
- # Steps represent a sequence of tasks that will be executed as part of the job
|
|
|
steps:
|
|
|
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
|
- - uses: actions/checkout@v2
|
|
|
-
|
|
|
- - name: Use Node.js
|
|
|
- uses: actions/[email protected]
|
|
|
+ # 拉取代码
|
|
|
+ - name: Checkout
|
|
|
+ uses: actions/checkout@v2
|
|
|
with:
|
|
|
- node-version: "12.x"
|
|
|
-
|
|
|
-
|
|
|
- # 如果缓存没有命中,安装依赖,根据实际来改,也可以是npm,这里是用的yarn
|
|
|
- - name: Install dependencies And Build
|
|
|
+ persist-credentials: false
|
|
|
+
|
|
|
+ # 生成静态文件
|
|
|
+ - name: Build
|
|
|
run: npm install && npm run docs:build
|
|
|
-
|
|
|
+
|
|
|
+ # 部署到 GitHub Pages
|
|
|
- name: Deploy
|
|
|
uses: JamesIves/github-pages-deploy-action@releases/v3
|
|
|
with:
|
|
|
- ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
|
- # 部署到 gh-pages 分支
|
|
|
- BRANCH: gh-pages
|
|
|
- # 部署目录为 VuePress 的默认输出目录,这里需要根据项目的目录进行修改
|
|
|
- FOLDER: docs/.vuepress/dist
|
|
|
+ ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # 也就是我们刚才生成的 secret
|
|
|
+ BRANCH: gh-pages # 部署到 gh-pages 分支,因为 main 分支存放的一般是源码,而 gh-pages 分支则用来存放生成的静态文件
|
|
|
+ FOLDER: docs/.vuepress/dist # vuepress 生成的静态文件存放的地方
|