Skip to content

Commit dfdea56

Browse files
committed
Extract deployment
1 parent ea780a6 commit dfdea56

File tree

2 files changed

+12
-91
lines changed

2 files changed

+12
-91
lines changed

.github/deploy.sh

100755100644
Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
#!/bin/bash
2-
3-
# Automatically deploy on gh-pages
1+
#! /bin/bash
42

53
set -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-
185
echo "Removing the current docs for master"
196
rm -rf out/master/ || exit 0
207

@@ -23,59 +10,34 @@ mkdir out/master/
2310
cp util/gh-pages/index.html out/master
2411
python ./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
3118
fi
3219

3320
# Generate version index that is shown as root index page
3421
cp util/gh-pages/versions.html out/index.html
35-
pushd out
3622

23+
cd out
3724
cat <<-EOF | python - > versions.json
3825
import os, json
3926
print json.dumps([
4027
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
4128
])
4229
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
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

5935
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
6238
fi
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
7740
git add .
7841
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
7942

80-
# Now that we're all set up, we can push.
8143
git push "$SSH_REPO" "$TARGET_BRANCH"

.github/workflows/deploy.yml

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,6 @@ jobs:
2626
path: 'out'
2727
- name: Deploy
2828
run: |
29-
set -ex
30-
31-
echo "Removing the current docs for master"
32-
rm -rf out/master/ || exit 0
33-
34-
echo "Making the docs for master"
35-
mkdir out/master/
36-
cp util/gh-pages/index.html out/master
37-
python ./util/export.py out/master/lints.json
38-
39-
if [[ -n $TAG_NAME ]]; then
40-
echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it"
41-
cp -r out/master "out/$TAG_NAME"
42-
rm -f out/current
43-
ln -s "$TAG_NAME" out/current
44-
fi
45-
46-
# Generate version index that is shown as root index page
47-
cp util/gh-pages/versions.html out/index.html
48-
49-
cd out
50-
cat <<-EOF | python - > versions.json
51-
import os, json
52-
print json.dumps([
53-
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
54-
])
55-
EOF
56-
57-
# Now let's go have some fun with the cloned repo
58-
git config user.name "GHA CI"
59-
git config user.email "gha@ci.invalid"
60-
61-
if git diff --exit-code --quiet; then
62-
echo "No changes to the output on this push; exiting."
63-
exit 0
64-
fi
65-
66-
git add .
67-
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
68-
6929
eval "$(ssh-agent -s)"
7030
ssh-add - <<< "${{ secrets.DEPLOY_KEY }}"
71-
72-
git push "$SSH_REPO" "$TARGET_BRANCH"
31+
bash .github/deploy.sh

0 commit comments

Comments
 (0)