-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (44 loc) · 1.51 KB
/
hugo.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
51
52
name: Build and deploy gh-pages
on:
push:
paths:
- 'docs/**'
- '.github/workflows/hugo.yml'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: 'docs/package-lock.json'
- name: Setup public worktree
run: cd docs && git worktree add public gh-pages
- name: Create a branch for pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd docs/public
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git push origin --delete gh-pages-github-action || true
git checkout -b gh-pages-github-action gh-pages
- name: Build pages
run: |
cd docs
npm install
npm run build
ls public
cd public && git status
- name: Deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd docs/public
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git add --all
git status
git diff-index --quiet HEAD || git commit -m "Update gh-pages" && git push --set-upstream origin gh-pages-github-action