-
Notifications
You must be signed in to change notification settings - Fork 8
76 lines (58 loc) · 2.47 KB
/
publish_documentation_to_github_pages.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Publish Documentation to GitHub Pages
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Clone R2Wiki
run: |
git clone https://github.com/risk-of-thunder/R2Wiki.wiki.git
- name: Prepare for publishing
id: prepare-publish
run: |
last_commit_hash_file="last_commit_hash.txt"
if [ ! -f $last_commit_hash_file ]; then
echo 0 > $last_commit_hash_file;
fi
cd R2Wiki.wiki
current_commit_hash=$(bash -c 'git rev-parse HEAD')
cd ..
last_commit_hash=$(cat $last_commit_hash_file)
if [ "$current_commit_hash" == "$last_commit_hash" ]; then
echo "should-publish-new-doc=false" >> $GITHUB_OUTPUT;
else
echo "should-publish-new-doc=true" >> $GITHUB_OUTPUT;
rm -rf docs
cd R2Wiki.wiki
for file in *_*.md; do file_path=${file//_//}; file_name=${file##*_}; directory_path=${file_path%/*}; mkdir -p "../docs/$directory_path"; mv "$file" "../docs/$directory_path/$file_name"; done
for file in *.md; do mkdir -p "../docs/"; if [[ "$file" != "Home.md" ]]; then mv "$file" "../docs/$file"; fi; done
cd ..
rm -rf R2Wiki.wiki
echo $current_commit_hash > $last_commit_hash_file
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add $last_commit_hash_file
git commit -m "[GitHub Action] Update last R2Wiki commit hash"
git add -A
git commit -m "[GitHub Action] Update docs"
fi
- name: Save changes to repo
if: steps.prepare-publish.outputs.should-publish-new-doc == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: MkDocs Deploy To GitHub Pages
if: steps.prepare-publish.outputs.should-publish-new-doc == 'true'
uses: mhausenblas/mkdocs-deploy-gh-pages@1.24
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONFIG_FILE: mkdocs.yml
EXTRA_PACKAGES: build-base
REQUIREMENTS: requirements.txt