-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgitlab-build-website.sh
More file actions
executable file
·40 lines (32 loc) · 916 Bytes
/
Copy pathgitlab-build-website.sh
File metadata and controls
executable file
·40 lines (32 loc) · 916 Bytes
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
#!/bin/bash
set -e
function err() {
echo "$1" >&2
exit 1
}
branch="$1"
[ -z "$branch" ] && branch="$CI_COMMIT_REF_NAME"
[ -z "$branch" ] && err "no branch specified"
url="$CI_REPOSITORY_URL"
[ -z "$url" ] && err "no url specified"
# clone pages website
html=public
rm -fr "$html"
git branch -f pages remotes/origin/pages
git clone -b pages . "$html"
rm -fr "$html"/"$branch"
# generate html
agda -i. --html --html-dir="$html"/"$branch" README.agda
mv "$html"/"$branch"/README.html "$html"/"$branch"/index.html
# push updated website
sha=`git log -1 HEAD --pretty=format:%H`
cd "$html"
git add -A
git config user.name "Paolo Capriotti"
git config user.email "paolo@capriotti.io"
git commit -m "Update $branch: $sha" || true
# use appropriate deploy token
url=$(echo "$url" | sed 's|^https://gitlab-ci-token:[^@]*|https://pcapriotti:'"$GITLAB_TOKEN|")
git push "$url" pages:pages
# cleanup
rm -fr .git