docs: banner ad #198
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions | |
name: deploy | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 14 | |
- name: build | |
run: | | |
echo "---------- node-version `node -v` ----------" | |
yarn install | |
echo "---------- yarn install ok ----------" | |
yarn build ## 打包出 html 到 docs/.vuepress/dist | |
echo "---------- yarn build ok ----------" | |
- name: set ssh key # 临时设置 ssh key | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{secrets.SSH_KEY_FOR_GITHUB_WANGEDITOR}}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan "github.com" >> ~/.ssh/known_hosts | |
echo "---------- set ssh-key ok ----------" | |
- name: download and replace # 下载现有文件,替换 | |
run: | | |
git clone [email protected]:wangEditor/wangEditor.github.io.git | |
echo "---------- git clone ok ----------" | |
cp -r ./docs/.vuepress/dist/* ./wangEditor.github.io ## 用最新构建出来的文件,替换现有的 | |
echo "---------- replace ok ----------" | |
- name: upload # 上传文件 | |
run: | | |
cd ./wangEditor.github.io | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
echo "---------- begin git status ----------" | |
echo `git status` | |
echo "---------- end git status ----------" | |
git add . | |
git commit -m "update by github actions" | |
echo "---------- begin git push ----------" | |
git push origin master | |
echo "---------- end git push ----------" | |
- name: delete ssh key # 删除 ssh key | |
run: rm -rf ~/.ssh/id_rsa |