1
- #! /bin/bash
2
-
3
- # Automatically deploy on gh-pages
1
+ #! /bin/bash
4
2
5
3
set -ex
6
4
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
-
18
5
echo " Removing the current docs for master"
19
6
rm -rf out/master/ || exit 0
20
7
@@ -23,59 +10,34 @@ mkdir out/master/
23
10
cp util/gh-pages/index.html out/master
24
11
python ./util/export.py out/master/lints.json
25
12
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
31
18
fi
32
19
33
20
# Generate version index that is shown as root index page
34
21
cp util/gh-pages/versions.html out/index.html
35
- pushd out
36
22
23
+ cd out
37
24
cat << -EOF | python - > versions.json
38
25
import os, json
39
26
print json.dumps([
40
27
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
41
28
])
42
29
EOF
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
53
30
54
31
# 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"
58
34
59
35
if 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
62
38
fi
63
- cd -
64
39
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
77
40
git add .
78
41
git commit -m " Automatic deploy to GitHub Pages: ${SHA} "
79
42
80
- # Now that we're all set up, we can push.
81
43
git push " $SSH_REPO " " $TARGET_BRANCH "
0 commit comments