-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (44 loc) · 1.63 KB
/
build.yml
1
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Github-Pages
# 在 master 分支更新时触发构建
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-18.04
env:
TZ: Asia/Shanghai
SOURCE_REPO: "he-sb/tech" # 博客源码仓库
TARGET_REPO: "he-sb/tech" # 博客部署仓库
TARGET_BRANCH: "gh-pages" # 博客部署的分支名
SECRET: ${{ secrets.PERSONAL_TOKEN }}
steps:
# 配置 git,避免一些莫名其妙的错误
- name: Git Configuration
run: |
git config --global core.quotePath false
git config --global core.autocrlf false
git config --global core.safecrlf true
git config --global core.ignorecase false
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# 拉取源码
- name: Clone Repository
run:
git clone --branch=master --quiet https://github.com/$SOURCE_REPO site
# 安装 hugo (v0.79.0)
- name: Setup Hugo
run:
wget -q -O hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.79.0/hugo_extended_0.79.0_Linux-64bit.deb && sudo dpkg -i hugo.deb && hugo version
# 构建网站
- name: Build
run:
cd site && hugo --gc --minify --cleanDestinationDir
# 部署至 GitHub Pages
- name: Deploy
run: |
cd site/public && git init
git add .
git commit -m "Update Blog By GitHub Actions With Build ${GITHUB_RUN_NUMBER}"
git push --force --quiet "https://$SECRET@github.com/$TARGET_REPO" master:$TARGET_BRANCH