俚语 #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# name 可以自定义 | |
name: docs | |
# 每当 push 到 main 分支时触发部署 | |
on: | |
push: | |
branches: | |
- master | |
# 任务 | |
jobs: | |
docs: | |
# 服务器环境:最新版 Ubuntu | |
runs-on: ubuntu-latest | |
steps: | |
# 拉取代码 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 | |
fetch-depth: 0 | |
- name: Setup Node.js # 步骤2 | |
uses: actions/setup-node@v1 # 作用:安装nodejs | |
with: | |
# 选择要使用的 node 版本 | |
node-version: "14" # 版本 | |
# 缓存 node_modules | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
# 如果缓存没有命中,安装依赖 | |
- name: Install dependencies | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: yarn install | |
# 运行构建脚本 | |
- name: Build VuePress site | |
run: yarn run build | |
# 查看 workflow 的文档来获取更多信息 | |
# @see https:/crazy-max/ghaction-github-pages | |
# 生成静态文件 | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/[email protected] | |
with: | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
BRANCH: gh-pages | |
FOLDER: docs/.vuepress/dist/ # vuepress 生成的静态文件存放的位置 | |
# 部署到 GitHub Pages | |
# - name: Deploy | |
# uses: JamesIves/github-pages-deploy-action@releases/v3 | |
# with: | |
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # 也就是我们刚才生成的 secret | |
# BRANCH: master # 部署到 master 分支,因为 master 分支存放的一般是源码,而 gh-pages 分支则用来存放生成的静态文件 | |
# FOLDER: docs/.vuepress/dist # vuepress 生成的静态文件存放的地方 |