#!/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

git clone --branch gh-pages git@github.com:$TRAVIS_REPO_SLUG docs

cd docs
git config user.name "autogenerated docs"
git config user.email "docs@dtolnay.github.io"
git rm -q '*'
mv ../target/doc/* .
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

git clone --branch gh-pages git@github.com:$TRAVIS_REPO_SLUG docs

cd docs
git config user.name "autogenerated docs"
git config user.email "docs@dtolnay.github.io"
git rm -q --ignore-unmatch '*'
mv ../target/doc/* .
git add -A .
git commit -qm "autogenerated docs for $TRAVIS_REPO_SLUG"
git push -q origin gh-pages

Allow git rm '*' on empty commit
Allow git rm '*' on empty commit
