diff --git a/.travis.yml b/.travis.yml index 29b4b52505..4a4c75d3de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,14 @@ sudo: false language: node_js -node_js: -- stable +node_js: stable cache: false -after_success: -- eval "$(ssh-agent -s)" -- openssl aes-256-cbc -K $encrypted_973441be79af_key -iv $encrypted_973441be79af_iv -in ./scripts/id_ed25519_tldr_asset_upload.enc -out id_ed25519 -d -- chmod 600 id_ed25519 -- ssh-add id_ed25519 -- bash scripts/build.sh - after_failure: -- cat test_result | python scripts/send_to_bot.py + - python scripts/send_to_bot.py < test_result + +deploy: + provider: script + script: bash scripts/deploy.sh + on: + branch: master diff --git a/scripts/build.sh b/scripts/deploy.sh similarity index 70% rename from scripts/build.sh rename to scripts/deploy.sh index 50b96665b3..5f3891c2b8 100644 --- a/scripts/build.sh +++ b/scripts/deploy.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This script is executed by Travis CI when a PR is merged (i.e. in the `after_success` step). +# This script is executed by Travis CI when a PR is merged (i.e. in the `deploy` step). set -ev function initialize { @@ -12,10 +12,17 @@ function initialize { export SITE_URL="github.com/tldr-pages/tldr-pages.github.io" export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io" + # Configure git. git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" git config --global push.default simple git config --global diff.zip.textconv "unzip -c -a" + + # Decrypt and add deploy key. + eval "$(ssh-agent -s)" + openssl aes-256-cbc -K $encrypted_973441be79af_key -iv $encrypted_973441be79af_iv -in ./scripts/id_ed25519_tldr_asset_upload.enc -out id_ed25519 -d + chmod 600 id_ed25519 + ssh-add id_ed25519 } function rebuild_index { @@ -24,7 +31,6 @@ function rebuild_index { function build_archive { rm -f $TLDR_ARCHIVE - cd $TLDRHOME/ zip -r $TLDR_ARCHIVE pages*/ LICENSE.md } @@ -44,13 +50,7 @@ function upload_assets { # MAIN ################################### -if [ ! "$TRAVIS_PULL_REQUEST" == "false" ]; then - echo "This is a Pull Request, no index rebuild needed" -elif [ ! "$TRAVIS_BRANCH" == "master" ]; then - echo "This is not a master branch, no index rebuild needed" -else - initialize - rebuild_index && echo "Rebuilding index is done" - build_archive && echo "Pages archive is created" - upload_assets && echo "Assets (pages archive, index) deployed to static site" -fi +initialize +rebuild_index && echo "Rebuilding index done." +build_archive && echo "Pages archive created." +upload_assets && echo "Assets (pages archive, index) deployed to static site."