forked from vsanthanam/NetworkReachability
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-static-site.sh
executable file
·50 lines (42 loc) · 1.11 KB
/
generate-static-site.sh
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
#!/bin/bash
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
run_docc () {
swift package --allow-writing-to-directory docs generate-documentation --target NetworkReachability --disable-indexing --transform-for-static-hosting --hosting-base-path docs --output-path docs --include-extended-types
}
create_branches () {
git branch -D gh-pages
git checkout -b gh-pages
}
fix_readme () {
tail -n +2 README.md > README-2.md && mv README-2.md README.md
}
configure_site () {
echo "reachability.tools" > CNAME
echo "theme: jekyll-theme-modernist" > _config.yml
}
commit_and_publish () {
git add .
git commit -m 'Synchronize Hompage & Publish Documentation'
git push -f -u origin gh-pages
}
clean_up () {
git checkout main
git branch -D gh-pages
rm -rf docs
}
generate_documentation () {
create_branches
run_docc
fix_readme
configure_site
commit_and_publish
clean_up
}
if [[ "$branch" != "main" ]]; then
echo "Invalid Branch"
elif [[ -n $(git status -s) ]]; then
echo "Uncommited Changes"
else
generate_documentation
echo "Website Updated!"
fi