忽然发现 GitHub Actions beta 的资格下来了,就想着折腾一下
顺便改了一下 Repo 的结构和部署脚本
1 2 3 4 5
| 原来 chaigidel.github.io:hexo --> Traivs CI --> chaigidel.github.io:master
现在 blog_source:master --> GitHub Actions --> chaigidel.github.io:master
|
GH_PAT
是 GitHub Presonal Access Token 勾上 Repo 权限就行
Page_repo
是 Chaigidel/chaigidel.github.io
publish-to-gh-pages.sh1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #!/bin/bash set -ev remote_repo="https://${GH_PAT}@github.com/${Page_repo}.git" remote_branch="master"
cd public git init git config user.name "GitHub Actions" git config user.email "[email protected]" git add .
git commit -m "Auto Builder at `date +"%Y-%m-%d %H:%M"` from ${GITHUB_REPOSITORY}" git push --force "${remote_repo}" master:${remote_branch}
echo "Deploy complete"
|
关于 secrets
的文档,在项目 settings->Secrets
里设置
.github/workflows/main.yml1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| name: CI on: push: branches: - master jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - uses: actions/setup-node@master with: node-version: 10.x - name: Install Dependencies run: | git submodule init git submodule update npm install -g hexo npm install - name: Clean run: hexo clean - name: Generate run: hexo generate - name: Checkdir run: ls ./public - name: Deploy env: GH_PAT: ${{ secrets.GH_PAT }} Page_repo: "Chaigidel/chaigidel.github.io" run: sh publish-to-gh-pages.sh
|