1- #! /bin/bash
2-
3- # Automatically deploy on gh-pages
1+ #! /bin/bash
42
53set -ex
64
7- SOURCE_BRANCH=" master"
8- TARGET_BRANCH=" gh-pages"
9-
10- # Save some useful information
11- REPO=$( git config remote.origin.url)
12- SSH_REPO=${REPO/ https: \/\/ github.com\/ / git@ github.com: }
13- SHA=$( git rev-parse --verify HEAD)
14-
15- # Clone the existing gh-pages for this repo into out/
16- git clone --quiet --single-branch --branch " $TARGET_BRANCH " " $REPO " out
17-
185echo " Removing the current docs for master"
196rm -rf out/master/ || exit 0
207
@@ -23,59 +10,34 @@ mkdir out/master/
2310cp util/gh-pages/index.html out/master
2411python ./util/export.py out/master/lints.json
2512
26- if [[ -n " $TRAVIS_TAG " ]]; then
27- echo " Save the doc for the current tag ($TRAVIS_TAG ) and point current/ to it"
28- cp -r out/master " out/$TRAVIS_TAG "
29- rm -f out/current
30- ln -s " $TRAVIS_TAG " out/current
13+ if [[ -n $TAG_NAME ]]; then
14+ echo " Save the doc for the current tag ($TAG_NAME ) and point current/ to it"
15+ cp -r out/master " out/$TAG_NAME "
16+ rm -f out/current
17+ ln -s " $TAG_NAME " out/current
3118fi
3219
3320# Generate version index that is shown as root index page
3421cp util/gh-pages/versions.html out/index.html
35- pushd out
3622
23+ cd out
3724cat << -EOF | python - > versions.json
3825import os, json
3926print json.dumps([
4027 dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
4128])
4229EOF
43- popd
44-
45- # Pull requests and commits to other branches shouldn't try to deploy, just build to verify
46- if [[ " $TRAVIS_PULL_REQUEST " != " false" ]] || [[ " $TRAVIS_BRANCH " != " $SOURCE_BRANCH " ]]; then
47- # Tags should deploy
48- if [[ -z " $TRAVIS_TAG " ]]; then
49- echo " Generated, won't push"
50- exit 0
51- fi
52- fi
5330
5431# Now let's go have some fun with the cloned repo
55- cd out
56- git config user.name " Travis CI"
57- git config user.email " travis@ci.invalid"
32+ git config user.name " GHA CI"
33+ git config user.email " gha@ci.invalid"
5834
5935if git diff --exit-code --quiet; then
60- echo " No changes to the output on this push; exiting."
61- exit 0
36+ echo " No changes to the output on this push; exiting."
37+ exit 0
6238fi
63- cd -
6439
65- # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
66- ENCRYPTION_LABEL=e3a2d77100be
67- ENCRYPTED_KEY_VAR=" encrypted_${ENCRYPTION_LABEL} _key"
68- ENCRYPTED_IV_VAR=" encrypted_${ENCRYPTION_LABEL} _iv"
69- ENCRYPTED_KEY=${! ENCRYPTED_KEY_VAR}
70- ENCRYPTED_IV=${! ENCRYPTED_IV_VAR}
71- openssl aes-256-cbc -K " $ENCRYPTED_KEY " -iv " $ENCRYPTED_IV " -in .github/deploy_key.enc -out .github/deploy_key -d
72- chmod 600 .github/deploy_key
73- eval " $( ssh-agent -s) "
74- ssh-add .github/deploy_key
75-
76- cd out
7740git add .
7841git commit -m " Automatic deploy to GitHub Pages: ${SHA} "
7942
80- # Now that we're all set up, we can push.
8143git push " $SSH_REPO " " $TARGET_BRANCH "
0 commit comments