-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_gh-pages.sh
executable file
·61 lines (52 loc) · 1.85 KB
/
build_gh-pages.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
#!/bin/bash
sudo gem install asciidoctor --version 1.5.8
# Don't create gh-pages from dirty working directory
if [ "`git status -s`" ]
then
echo "The working directory is dirty. Please commit any pending changes."
exit 1;
fi
# Remember current commit hash
GIT_COMMIT_HASH=$(git rev-parse HEAD)
# Mount the gh-pages branch in a git worktree
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*;
git fetch --unshallow origin gh-pages
GH_PAGES=$(mktemp --directory --dry-run --tmpdir kilt_gh-pages.XXXXXXXXX)
git worktree add -b gh-pages "$GH_PAGES" origin/gh-pages
# Convert the asciidoc sources to HTML
asciidoctor \
--verbose \
--backend=html5 \
--attribute=nofooter \
--attribute="revdate=$(date -Idate)" \
--destination-dir="$GH_PAGES" \
--source-dir=docs \
docs/*.adoc
# Unsetting author and email doesn't work \
#asciidoctor \
# --backend=html5 \
# --attribute=nofooter \
# --attribute='!author' # do not print the author name \
# --attribute='!email' # do not print the email address \
# --attribute="revnumber=$KILT_VERSION" # specify the kilt revision \
# --attribute="revdate=$(date -Idate)" # set the current date \
# --destination-dir="$GH_PAGES" \
# --source-dir=docs \
# docs/*.adoc
# Copy the additional resources to the target directory
pushd docs
find . -type f -not -name "*.adoc" -exec cp '{}' "$GH_PAGES"/'{}' ';'
popd
# Commit the new content
pushd "$GH_PAGES"
git add --all
git config user.name "github-actions@github.org";
git config user.email "Github Actions";
git commit -m "[build_gh-pages.sh] Update gh-pages from ""$GIT_COMMIT_HASH"
# Push content
git push https://x-access-token:${GITHUB_ACCESS_TOKEN}@github.com/hupfdule/kilt.git
# Remove git worktree
popd
# travis' version of git is too old to support 'worktree remove'
#git worktree remove "$GH_PAGES"
git worktree prune