-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (72 loc) · 2.31 KB
/
render-site.yaml
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Reference: https://nathan-at-least.github.io/auto-deploy-howto.html
name: Deploy Rendered Site
on:
push:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
render-and-deploy:
runs-on: ubuntu-latest
steps:
# These initial steps set up the toolchain:
- name: Rust Toolchain Version Diagnostics
run: cargo --version --verbose && rustup --version
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]
- uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]
- uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]
- uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]
- uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]
# Now get the user content:
- uses: actions/checkout@v3
# Now render to the site:
# Each deploy overwrites the contents of `gh-pages` branch from
# `main`, but also introduces a merge structure so that the history of
# `gh-pages` is tracked:
- name: Overwrite gh-pages branch with main branch
run: |
set -x
BASE_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
git config --global user.name 'autodeploy'
git config --global user.email 'autodeploy'
git fetch
git checkout gh-pages # ensure we have local branch
git checkout "$BASE_BRANCH"
TMP='local-temp-branch'
git checkout -b "$TMP" # Same tree state as main branch
git merge \
--strategy ours \
--commit \
-m 'Auto-deploy: overwriting with `main` branch' \
--allow-unrelated-histories \
gh-pages
git checkout gh-pages
git merge --ff-only "$TMP"
git branch -d "$TMP"
- run: mdbook build
- name: Move generated HTML to docs/
run: |
rm docs
mv build/html/ docs/
- name: Rendered manifest
run: find ./docs -type f -exec ls -ld '{}' \;
- name: Disable jekyll
run: touch .nojekyll
- name: Commit and Push render to gh-pages
run: |
set -x
git add --all
git commit -m 'Auto-deploy: rendered output'
git push