Skip to content

Commit

Permalink
Improve manual deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
gracjan committed May 7, 2016
1 parent 163f264 commit 9da30b1
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions doc/deploy-manual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ if [[ "${TRAVIS_REPO_SLUG:-}" != "haskell/haskell-mode" ]]; then
exit 0
fi

if [[ "${TRAVIS_BRANCH:-}" != "master" ]]; then
echo "TRAVIS_BRANCH is '${TRAVIS_BRANCH:-}' expected 'master'"
if [[ "${TRAVIS_BRANCH:-}" != "master" && "${TRAVIS_BRANCH:-}" != branch-* ]]; then
echo "TRAVIS_BRANCH is '${TRAVIS_BRANCH:-}' expected 'master' or 'branch-*'"
echo "Manual deployment available only for 'master' branch"
exit 0
fi
Expand All @@ -21,38 +21,59 @@ if [[ -z "${GITHUB_DEPLOY_KEY_PASSPHRASE:-}" ]]; then
exit 0
fi

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

eval $(ssh-agent)
ssh-add haskell-mode-travis-deploy-key-plain
eval $(ssh-agent)
ssh-add haskell-mode-travis-deploy-key-plain
fi

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

# Documentation directory name

if [[ ${TRAVIS_BRANCH} == "master" ]]; then
DOCDIR="latest"
else
DOCDIR="${TRAVIS_BRANCH//branch-/}"
fi

HEAD_COMMIT=$(git rev-parse --short HEAD)

if [ -d gh-pages-deploy ]; then
rm -fr gh-pages-deploy
fi

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

cd gh-pages-deploy
git rm -qr manual/latest
cp -r ../html manual/latest
find manual/latest -name '*.html' -exec sed -i -e '/^<\/head>$/i\
if [[ -d "manual/${DOCDIR}" ]]; then
git rm -qr "manual/${DOCDIR}"
fi

cp -r ../html "manual/${DOCDIR}"
find "manual/${DOCDIR}" -name '*.html' -exec sed -i '~' -e '/^<\/head>$/i\
<script src="../../index.js"> </script>
' \{} \;
git add manual/latest
(git commit -m "Update manual from haskell/haskell-mode@${HEAD_COMMIT}" && git push origin gh-pages) || true
find "manual/${DOCDIR}" -name '*~' -exec rm \{} \;
git add "manual/${DOCDIR}"
if [[ ${GITHUB_DEPLOY_KEY_PASSPHRASE:-} != "skip" ]]; then
(git commit -m "Update manual for '${DOCDIR}' from haskell/haskell-mode@${HEAD_COMMIT}" && git push origin gh-pages) || true
else
echo "Update manual for '${DOCDIR}' from haskell/haskell-mode@${HEAD_COMMIT}"
fi
cd ..
rm -fr gh-pages-deploy

eval $(ssh-agent -k)
if [[ ${GITHUB_DEPLOY_KEY_PASSPHRASE:-} != "skip" ]]; then
rm -fr gh-pages-deploy
eval $(ssh-agent -k)
fi

echo Done!

0 comments on commit 9da30b1

Please sign in to comment.