[owner add]新增微信 #413
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: GitHub pages deploy | |
# 自动部署的条件 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
# 构建网站并部署到 GitHub Pages | |
deploy-gh-pages: | |
# 运行环境 | |
runs-on: ubuntu-latest | |
# 步骤 | |
steps: | |
# 第一步: 下载源码 | |
- name: Checkout | |
# action 配置详见 https://github.com/actions/checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
# 缓存 node_modules 以避免重复安装 | |
- uses: actions/[email protected] | |
id: node-modules | |
with: | |
# 需要缓存的路径 | |
path: node_modules/ | |
# 缓存的 key | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} | |
# 恢复 key | |
restore-keys: | | |
${{ runner.os }}-node-modules- | |
# 安装依赖 | |
- name: Install Deps | |
# 只有没有命中缓存才会执行 | |
if: steps.node-modules.outputs.cache-hit != 'true' | |
# 严格按照 yarn.lock 安装依赖 | |
run: yarn install --frozen-lockfile | |
# 构建项目 | |
- name: Build | |
# 项目的构建命令 | |
run: yarn run docs:build | |
# 第四步,部署 | |
- name: Deploy | |
# action 配置详见 https://github.com/JamesIves/github-pages-deploy-action | |
uses: JamesIves/[email protected] | |
with: | |
# 部署到的分支 | |
branch: gh-pages | |
# 需要部署的文件夹 | |
folder: dist | |
# 部署到服务器 | |
deploy-server: | |
runs-on: ubuntu-latest | |
# 确保在部署到 GitHub Pages 之后执行 | |
needs: deploy-gh-pages | |
steps: | |
# 检出网站代码 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
# 检出 gh-pages 分支 | |
ref: gh-pages | |
# 获取全部的历史提交 | |
fetch-depth: 0 | |
# 配置环境 | |
- name: Configuration environment | |
# 写入私钥、配置 Git 用户名,写入服务器地址 | |
# 您需要自行将服务器的私钥写入 secrets 的 SSH_PRIVATE_KEY | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan 139.196.230.188 >> ~/.ssh/known_hosts | |
git config --global user.name 'clay-wangzhi' | |
git config --global user.email '[email protected]' | |
# 部署到服务器 | |
- name: Deploy | |
# 使用 Git 将网站代码强制推送到远程的网站目录 | |
# 并使用 SSH 连接服务器进入网站目录手动切换到最新提交 | |
run: | | |
git push -f [email protected]:/home/git/wiki gh-pages | |
ssh [email protected] "cd /home/git/wiki && git reset --hard HEAD" |