-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (45 loc) · 1.56 KB
/
publish.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
53
54
55
# When a push is made to any branch named pages/<project>/<version>, update
# the gh-pages branch with a copy of the newly pushed content.
name: Publish
on:
push:
branches:
- 'pages/**'
concurrency:
# Prevent overlapping runs of this workflow, which would cause a race on the
# gh-pages branch.
group: publish-to-gh-pages
cancel-in-progress: false
jobs:
update-html:
name: Update docs for project/version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # All refs and history
path: apidoc
- run: |
pages_ref=${{ github.ref }} # refs/heads/pages/proj/ver
pages_branch=${pages_ref#refs/heads/} # pages/proj/ver
pages_path=${pages_branch#pages/} # proj/ver
cd apidoc
git archive -o ../pages.tar $pages_branch
if ! git checkout gh-pages --; then
git checkout --orphan gh-pages
git rm -rf .
else
git rm -rf --ignore-unmatch $pages_path
fi
mkdir -p $pages_path
tar xf ../pages.tar -C $pages_path
rm -rf $pages_path/.github
git add $pages_path
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
if [ -z "$(git status --porcelain=v1 2>/dev/null)" ]; then
echo "No changes to commit"
else
git commit -m "Autoupdate $pages_path"
git push -u origin gh-pages
fi