#!/bin/sh

# License: CC0 1.0 Universal
# https://creativecommons.org/publicdomain/zero/1.0/legalcode

set -ex

[ "$TRAVIS_BRANCH" = master ]

[ "$TRAVIS_PULL_REQUEST" = false ]

[ "$TRAVIS_RUST_VERSION" = nightly ]

SSH_KEY_TRAVIS_ID=62c0b5029e24
eval key=\$encrypted_${SSH_KEY_TRAVIS_ID}_key
eval iv=\$encrypted_${SSH_KEY_TRAVIS_ID}_iv

mkdir -p ~/.ssh
openssl aes-256-cbc -K $key -iv $iv -in scripts/upload_key.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa

# TODO use --depth=1 once on git 1.9
git clone --branch gh-pages git@github.com:$TRAVIS_REPO_SLUG docs.tmp
mv docs.tmp/.git docs
mv target/doc/* docs
cd docs

git config user.name "autogenerated docs"
git config user.email "docs@dtolnay.github.io"
git add -A .
git commit -qm "Autogenerated docs for $TRAVIS_REPO_SLUG"
git push -q origin gh-pages

#!/bin/sh

# License: CC0 1.0 Universal
# https://creativecommons.org/publicdomain/zero/1.0/legalcode

set -ex

[ "$TRAVIS_BRANCH" = master ]

[ "$TRAVIS_PULL_REQUEST" = false ]

[ "$TRAVIS_RUST_VERSION" = nightly ]

SSH_KEY_TRAVIS_ID=62c0b5029e24
eval key=\$encrypted_${SSH_KEY_TRAVIS_ID}_key
eval iv=\$encrypted_${SSH_KEY_TRAVIS_ID}_iv

mkdir -p ~/.ssh
openssl aes-256-cbc -K "$key" -iv "$iv" -in scripts/upload_key.enc -out ~/.ssh/id_rsa -d
chmod 600 ~/.ssh/id_rsa

COMMIT=$(git rev-parse --short HEAD)
OWNER=${TRAVIS_REPO_SLUG%%/*}

# TODO use --depth=1 once on git 1.9
git clone --branch gh-pages "git@github.com:$TRAVIS_REPO_SLUG" docs.tmp
mv docs.tmp/.git docs
mv target/doc/* docs
cd docs

git config user.name "autogenerated docs"
git config user.email "docs@${OWNER}.github.io"
git add -A .
git commit -qm "Autogenerated docs for ${TRAVIS_REPO_SLUG}@${COMMIT}"
git push -q origin gh-pages

Include git hash in autogenerated docs commit message
Include git hash in autogenerated docs commit message
