Skip to content

Commit f648fa6

Browse files
committed
Add deployment to GHA
1 parent 0c0f012 commit f648fa6

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: master
6+
release:
7+
types: [created]
8+
9+
env:
10+
TARGET_BRANCH: 'gh-pages'
11+
SHA: '${{ github.sha }}'
12+
SSH_REPO: '[email protected]:${{ github.repository }}.git'
13+
TAG_NAME: '${{ github.event.release.GITHUB_REF }}'
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/[email protected]
22+
- name: Checkout
23+
uses: actions/[email protected]
24+
with:
25+
ref: ${{ env.TARGET_BRANCH }}
26+
path: 'out'
27+
- name: Deploy
28+
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+
69+
eval "$(ssh-agent -s)"
70+
ssh-add - <<< "${{ secrets.DEPLOY_KEY }}"
71+
72+
git push "$SSH_REPO" "$TARGET_BRANCH"

0 commit comments

Comments
 (0)