自动化部署流程优化,关键信息自动获取

This commit is contained in:
Dongua 2022-07-09 10:32:00 +08:00 committed by GitHub
parent 07f93f17b1
commit 15cbf13723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 5 deletions

View File

@ -26,11 +26,25 @@ jobs:
uses: actions/setup-node@v1 # 作用安装nodejs uses: actions/setup-node@v1 # 作用安装nodejs
with: with:
node-version: ${{ matrix.node-version }} # 版本 node-version: ${{ matrix.node-version }} # 版本
- name: run deploy.sh # 步骤3 - name: build-commit-push # 步骤3
env: # 设置环境变量 run: |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} remote_addr=`git remote get-url --push origin`
CODING_TOKEN: ${{ secrets.CODING_TOKEN }} commit_info=`git describe --all --always --long`
run: npm install && npm run deploy user_name=`git log -1 --pretty=format:'%an'`
user_email=`git log -1 --pretty=format:'%ae'`
npm install
npm run build
cd docs/.vuepress/dist
git config --global init.defaultBranch hp-pages
git init
git config user.name ${user_name}
git config user.email ${user_email}
git add -A
git commit -m "auto deploy, $commit_info"
remote_addr=`echo $remote_addr | awk -F'://' '{print $2}'`
remote_addr=https://${user_name}:${{secrets.GITHUB_TOKEN}}@${remote_addr}
git remote add origin ${remote_addr}
git push origin HEAD:gh-pages --force # 推送到github gh-pages分支
# 如只提交到github pages可以使用github-pages-deploy-action详见: https://github.com/JamesIves/github-pages-deploy-action # 如只提交到github pages可以使用github-pages-deploy-action详见: https://github.com/JamesIves/github-pages-deploy-action