diff options
| author | Lzu Tao <taolzu@gmail.com> | 2019-10-21 15:09:53 +0700 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2019-10-22 10:14:39 +0700 |
| commit | b869eeb2a451c8ae84d111e9885df4677c4f9446 (patch) | |
| tree | c35956b62229d273c54550a9faded7dba2471034 /.github/deploy.sh | |
| parent | 1d0f62570b2f58b09b991f7312dd1f1564c613f0 (diff) | |
build: improve script and travis config
* fix a diff failure on windows See https://travis-ci.com/rust-lang/rust-clippy/jobs/245971932#L1625 for an example. * use cmp instead of diff > /dev/null * clone single branch instead of clone then checking out * do not decrypt key if have no diff change
Diffstat (limited to '.github/deploy.sh')
| -rwxr-xr-x | .github/deploy.sh | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/.github/deploy.sh b/.github/deploy.sh index a242c35c3ae..b8209159284 100755 --- a/.github/deploy.sh +++ b/.github/deploy.sh @@ -13,11 +13,7 @@ SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} SHA=$(git rev-parse --verify HEAD) # Clone the existing gh-pages for this repo into out/ -( - git clone "$REPO" out - cd out - git checkout $TARGET_BRANCH -) +git clone --quiet --single-branch --branch "$TARGET_BRANCH" "$REPO" out echo "Removing the current docs for master" rm -rf out/master/ || exit 0 @@ -27,7 +23,7 @@ mkdir out/master/ cp util/gh-pages/index.html out/master python ./util/export.py out/master/lints.json -if [ -n "$TRAVIS_TAG" ]; then +if [[ -n "$TRAVIS_TAG" ]]; then echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it" cp -r out/master "out/$TRAVIS_TAG" rm -f out/current @@ -35,27 +31,36 @@ if [ -n "$TRAVIS_TAG" ]; then fi # Generate version index that is shown as root index page -( - cp util/gh-pages/versions.html out/index.html - - cd out - python -c '\ - import os, json;\ - print json.dumps([\ - dir for dir in os.listdir(".")\ - if not dir.startswith(".") and os.path.isdir(dir)\ - ])' > versions.json -) +cp util/gh-pages/versions.html out/index.html +pushd out + +cat <<-EOF | python - > versions.json +import os, json +print json.dumps([ + dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir) +]) +EOF +popd # Pull requests and commits to other branches shouldn't try to deploy, just build to verify -if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then +if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] || [[ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]]; then # Tags should deploy - if [ -z "$TRAVIS_TAG" ]; then + if [[ -z "$TRAVIS_TAG" ]]; then echo "Generated, won't push" exit 0 fi fi +# Now let's go have some fun with the cloned repo +cd out +git config user.name "Travis CI" +git config user.email "travis@ci.invalid" + +if git diff --exit-code --quiet; then + echo "No changes to the output on this push; exiting." + exit 0 +fi + # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc ENCRYPTION_LABEL=e3a2d77100be ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" @@ -64,19 +69,9 @@ ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d chmod 600 .github/deploy_key -eval $(ssh-agent -s) +eval "$(ssh-agent -s)" ssh-add .github/deploy_key -# Now let's go have some fun with the cloned repo -cd out -git config user.name "Travis CI" -git config user.email "travis@ci.invalid" - -if [ -z "$(git diff --exit-code)" ]; then - echo "No changes to the output on this push; exiting." - exit 0 -fi - git add . git commit -m "Automatic deploy to GitHub Pages: ${SHA}" |
