Skip to content

Commit 9da30b1

Browse files
committed
Improve manual deployment script
1 parent 163f264 commit 9da30b1

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

doc/deploy-manual.sh

+37-16
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if [[ "${TRAVIS_REPO_SLUG:-}" != "haskell/haskell-mode" ]]; then
99
exit 0
1010
fi
1111

12-
if [[ "${TRAVIS_BRANCH:-}" != "master" ]]; then
13-
echo "TRAVIS_BRANCH is '${TRAVIS_BRANCH:-}' expected 'master'"
12+
if [[ "${TRAVIS_BRANCH:-}" != "master" && "${TRAVIS_BRANCH:-}" != branch-* ]]; then
13+
echo "TRAVIS_BRANCH is '${TRAVIS_BRANCH:-}' expected 'master' or 'branch-*'"
1414
echo "Manual deployment available only for 'master' branch"
1515
exit 0
1616
fi
@@ -21,38 +21,59 @@ if [[ -z "${GITHUB_DEPLOY_KEY_PASSPHRASE:-}" ]]; then
2121
exit 0
2222
fi
2323

24-
# Note: GITHUB_DEPLOY_KEY_PASSPHRASE comes from 'secure' section in .travis.yml
25-
cp haskell-mode-travis-deploy-key haskell-mode-travis-deploy-key-plain
26-
chmod 0600 haskell-mode-travis-deploy-key-plain
27-
ssh-keygen -f haskell-mode-travis-deploy-key-plain -P $GITHUB_DEPLOY_KEY_PASSPHRASE -p -N ""
24+
if [[ ${GITHUB_DEPLOY_KEY_PASSPHRASE:-} != "skip" ]]; then
25+
# Note: GITHUB_DEPLOY_KEY_PASSPHRASE comes from 'secure' section in .travis.yml
26+
cp haskell-mode-travis-deploy-key haskell-mode-travis-deploy-key-plain
27+
chmod 0600 haskell-mode-travis-deploy-key-plain
28+
ssh-keygen -f haskell-mode-travis-deploy-key-plain -P $GITHUB_DEPLOY_KEY_PASSPHRASE -p -N ""
2829

29-
eval $(ssh-agent)
30-
ssh-add haskell-mode-travis-deploy-key-plain
30+
eval $(ssh-agent)
31+
ssh-add haskell-mode-travis-deploy-key-plain
32+
fi
3133

3234
# Git setup, this commit should appear as if Travis made it
3335
export GIT_COMMITTER_EMAIL='[email protected]'
3436
export GIT_COMMITTER_NAME='Travis CI'
3537
export GIT_AUTHOR_EMAIL='[email protected]'
3638
export GIT_AUTHOR_NAME='Travis CI'
3739

40+
# Documentation directory name
41+
42+
if [[ ${TRAVIS_BRANCH} == "master" ]]; then
43+
DOCDIR="latest"
44+
else
45+
DOCDIR="${TRAVIS_BRANCH//branch-/}"
46+
fi
47+
3848
HEAD_COMMIT=$(git rev-parse --short HEAD)
3949

4050
if [ -d gh-pages-deploy ]; then
4151
rm -fr gh-pages-deploy
4252
fi
4353

44-
git clone --quiet --branch=gh-pages "[email protected]:haskell/haskell-mode.git" gh-pages-deploy
54+
git clone --quiet --depth 1 --branch=gh-pages "[email protected]:haskell/haskell-mode.git" gh-pages-deploy
4555

4656
cd gh-pages-deploy
47-
git rm -qr manual/latest
48-
cp -r ../html manual/latest
49-
find manual/latest -name '*.html' -exec sed -i -e '/^<\/head>$/i\
57+
if [[ -d "manual/${DOCDIR}" ]]; then
58+
git rm -qr "manual/${DOCDIR}"
59+
fi
60+
61+
cp -r ../html "manual/${DOCDIR}"
62+
find "manual/${DOCDIR}" -name '*.html' -exec sed -i '~' -e '/^<\/head>$/i\
5063
<script src="../../index.js"> </script>
5164
' \{} \;
52-
git add manual/latest
53-
(git commit -m "Update manual from haskell/haskell-mode@${HEAD_COMMIT}" && git push origin gh-pages) || true
65+
find "manual/${DOCDIR}" -name '*~' -exec rm \{} \;
66+
git add "manual/${DOCDIR}"
67+
if [[ ${GITHUB_DEPLOY_KEY_PASSPHRASE:-} != "skip" ]]; then
68+
(git commit -m "Update manual for '${DOCDIR}' from haskell/haskell-mode@${HEAD_COMMIT}" && git push origin gh-pages) || true
69+
else
70+
echo "Update manual for '${DOCDIR}' from haskell/haskell-mode@${HEAD_COMMIT}"
71+
fi
5472
cd ..
55-
rm -fr gh-pages-deploy
5673

57-
eval $(ssh-agent -k)
74+
if [[ ${GITHUB_DEPLOY_KEY_PASSPHRASE:-} != "skip" ]]; then
75+
rm -fr gh-pages-deploy
76+
eval $(ssh-agent -k)
77+
fi
78+
5879
echo Done!

0 commit comments

Comments
 (0)