forked from obonaventure/pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·127 lines (117 loc) · 3.46 KB
/
main.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
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# set -x
set -e
repo_dir=$GITHUB_WORKSPACE/$INPUT_REPOSITORY_PATH
doc_dir=$repo_dir/$INPUT_DOCUMENTATION_PATH
echo ::group:: Initialize various paths
echo Workspace: $GITHUB_WORKSPACE
echo Repository: $repo_dir
echo Documentation: $doc_dir
echo ::endgroup::
# The actions doesn't depends on any images,
# so we have to try various package manager.
echo ::group:: Installing Sphinx
if command -v pip3 &>/dev/null; then
echo Found pip3 in system path
elif command -v apt &>/dev/null; then
# Debian/Ubuntu
echo Installing pip3 via apt
sudo apt update
sudo apt install python3-pip python3-setuptools
elif command -v zypper &>/dev/null; then
# openSUSE
echo Installing pip3 via zypper
sudo zypper update
sudo zypper install python3-pip python3-setuptools
elif command -v yum &>/dev/null; then
# RHEL, CentOS
echo Installing pip3 via yum
sudo yum update
sudo yum install python-pip python-setuptools
elif command -v pacman &>/dev/null; then
# ArchLinux
echo Installing pip3 via pacman
sudo pacman -Syy
sudo pacman -S python-pip python-setuptools
elif command -v brew &>/dev/null; then
# macOS
echo Installing pip3 via homebrew
brew update
brew install python
fi
if ! command -v pip3 &>/dev/null; then
echo Pip is not successfully installed
exit 1
else
echo Pip is successfully installed
fi
echo Installing sphinx via pip
pip3 install -U sphinx==3.5.4
echo Adding user bin to system path
PATH=$HOME/.local/bin:$PATH
if ! command -v sphinx-build &>/dev/null; then
echo Sphinx is not successfully installed
exit 1
else
echo Everything goes well
fi
echo ::endgroup::
if [ "$INPUT_INSTALL_REQUIREMENTS" = "true" ] ; then
echo ::group:: Installing requirements
if [ -f "$doc_dir/requirements.txt" ]; then
echo Installing python requirements
pip3 install -r $doc_dir/requirements.txt
else
echo No requirements.txt found, skipped
fi
echo ::endgroup::
fi
echo ::group:: Creating temp directory
tmp_dir=$(mktemp -d -t pages-XXXXXXXXXX)
echo Temp directory \"$tmp_dir\" is created
echo ::endgroup::
#echo ::group:: Converting images
#cd pkt
#make
#cd ..
#echo ::endgroup::
echo ::group:: Running Sphinx builders
sphinx-build -W -b spelling $doc_dir $tmp_dir
sphinx-build -M latexpdf $doc_dir $tmp_dir
sphinx-build -b epub $doc_dir $tmp_dir
sphinx-build -b singlehtml $doc_dir $tmp_dir
echo ::endgroup::
# to be replaced by an artifact
#echo ::group:: Setting up git repository
#echo Setting up git configure
#cd $repo_dir
#git config --local user.email "[email protected]"
#git config --local user.name "GitHub Action"
#git stash
#echo Setting up branch $INPUT_TARGET_BRANCH
#branch_exist=$(git ls-remote --heads origin refs/heads/$INPUT_TARGET_BRANCH)
#if [ -z "$branch_exist" ]; then
# echo Branch doesn\'t exist, create an emptry branch
# git checkout --force --orphan $INPUT_TARGET_BRANCH
#else
# echo Branch exists, checkout to it
# git checkout --force $INPUT_TARGET_BRANCH
#fi
#git clean -fd
#echo ::endgroup::
#
#echo ::group:: Committing HTML documentation
#cd $repo_dir
#echo Deleting all file in repository
#rm -vrf *
#echo Copying HTML documentation to repository
#cp -vr $tmp_dir/. .
#echo Adding HTML documentation to repository index
#git add .
#echo Checking out extra files
#for f in $INPUT_EXTRA_FILES; do
# git checkout $GITHUB_REF $f
#done
#echo Recording changes to repository
#git commit --allow-empty -m "Add changes for $GITHUB_SHA"
#echo ::endgroup::