Skip to content

Commit ac570f7

Browse files
committed
Extract deployment
1 parent c3b1f82 commit ac570f7

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

.github/deploy.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#! /bin/bash
2+
3+
set -ex
4+
5+
echo "Removing the current docs for master"
6+
rm -rf out/master/ || exit 0
7+
8+
echo "Making the docs for master"
9+
mkdir out/master/
10+
cp util/gh-pages/index.html out/master
11+
python ./util/export.py out/master/lints.json
12+
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
18+
fi
19+
20+
# Generate version index that is shown as root index page
21+
cp util/gh-pages/versions.html out/index.html
22+
23+
cd out
24+
cat <<-EOF | python - > versions.json
25+
import os, json
26+
print json.dumps([
27+
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
28+
])
29+
EOF
30+
31+
# Now let's go have some fun with the cloned repo
32+
git config user.name "GHA CI"
33+
git config user.email "[email protected]"
34+
35+
if git diff --exit-code --quiet; then
36+
echo "No changes to the output on this push; exiting."
37+
exit 0
38+
fi
39+
40+
git add .
41+
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
42+
43+
git push "$SSH_REPO" "$TARGET_BRANCH"

.github/workflows/deploy.yml

+1-42
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 "[email protected]"
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)