forked from godotengine/godot-docs
-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.sh
executable file
·117 lines (95 loc) · 3.06 KB
/
build.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Init env vars
date=`date`
workDir=`pwd`
sshCommand="ssh -v" # Add -v, -vv, or -vvv for verbose debugging
gitBranch=`git rev-parse --abbrev-ref HEAD`
if [ -n "$CF_PAGES" ]
then
echo "We are on Cloudflare Pages. Retrieve branch from env."
gitBranch=$CF_PAGES_BRANCH
fi
liveDir=$gitBranch
if [ $gitBranch == "master" ]
then
liveDir="latest"
fi
gitCommitMessage="branch $gitBranch on $date, will deploy to $liveDir"
redotDocsLiveBranch=${1:-develop}
inputDir="."
migrateDir="_migrated"
sphinxDir="_sphinx"
repoDir="_repo"
liveRoot="redot-docs-live"
liveRepo="[email protected]:Redot-Engine/$liveRoot.git"
buildDir="html/en/$liveDir" # TODO: implement i18n support
# Report vars and intention
echo "Building $gitCommitMessage"
echo "Live branch: $redotDocsLiveBranch"
echo "Live root: $liveRoot, live repo: $liveRepo, build dir: $buildDir, report dir: $reportDir"
echo "Temp dirs: $migrateDir, $sphinxDir, $repoDir"
echo "Delete temp dirs"
rm -rf $migrateDir
rm -rf $sphinxDir
rm -rf $repoDir
mkdir -p $migrateDir
mkdir -p $sphinxDir
if [ -n "$FULL_RUN" ]
then
echo "Migrate Godot to Redot"
python migrate.py $inputDir $migrateDir
echo "Translate to html"
sphinx-build -b html -j 4 $migrateDir $sphinxDir
fi
echo "DUMMY FILE FOR TESTING: $date" > $sphinxDir/test.html
echo "Cloning $liveRepo $repoDir"
git clone $liveRepo $repoDir
cd $repoDir
echo "Checking out $redotDocsLiveBranch"
git checkout $redotDocsLiveBranch
git config core.sshCommand "$sshCommand"
echo "Using ssh command: $sshCommand"
if [ -n "$CF_PAGES" ]
then
echo "We are on Cloudflare Pages. Setting custom ssh key and method"
# HACK: Remove annoying https redirect. I presume this was used by Cloudflare
echo "Remove Cloudflare redirect."
insteadof=`git config --list | grep insteadof`
remove=`echo $insteadof | cut -d "=" -f 1`
git config --global --unset $remove
mkdir ~/.ssh
echo "$BUILD_SSH_KEY" > ~/.ssh/id_ed25519
echo "$BUILD_SSH_KEY_PUB" > ~/.ssh/id_ed25519.pub
echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 0600 ~/.ssh/id_ed25519
chmod 0600 ~/.ssh/id_ed25519.pub
chmod 0644 ~/.ssh/known_hosts
chmod 0755 ~/.ssh
# Init git
git remote set-url origin [email protected]:Redot-Engine/redot-docs-live.git
echo "Setting credentials"
git config user.email "[email protected]"
git config user.name "Redot Docs Build Worker"
fi
echo "### SSH CONFIG VALUES ###"
ls -la ~/.ssh
cat ~/.ssh/known_hosts
echo "### SSH TEST ###"
ssh -T -vv [email protected]
echo "### GIT CONFIG VALUES ###"
git config core.pager cat
git config --list
echo "Copying generated content to repository"
echo "mkdir -p $buildDir"
mkdir -p $buildDir
echo "cp -r ../$sphinxDir/* $buildDir"
cp -r ../$sphinxDir/* $buildDir
echo "Commit and push to $redotDocsLiveBranch, with message $gitCommitMessage"
git add .
git commit --message "$gitCommitMessage"
git push --force
# Create some output so Cloudflare is happy
cd ..
mkdir -p ./output
echo "Build finished. Commit message: $gitCommitMessage" > ./output/index.html
echo "Done. Made by @Craptain"