-
Notifications
You must be signed in to change notification settings - Fork 4k
94 lines (92 loc) · 2.89 KB
/
build-and-deploy-website.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build and deploy offline website
on:
push:
branches:
- master
jobs:
build:
name: Build offline website
runs-on: ubuntu-20.04 #ubuntu-latest ubuntu latest have some bug, we need to use older one
env:
CI: true
WORKFLOW_GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
steps:
- name: Setup Action
uses: actions/checkout@v1
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 12.x
- name: Setup Python
uses: actions/[email protected]
with:
python-version: '3.x'
- name: Install Python dependencies
run: make install-python-requirements
- name: Run build script
run: cd scripts && bash Generate_Site_mkDocs.sh
- name: List generated files
run: ls -al generated/site/
- name: Create bundle
run: cd generated && zip -r ../bundle.zip site
- name: Test bundle
run: zip -T bundle.zip
- name: Upload bundle as artifact
uses: actions/[email protected]
with:
name: Bundle
path: bundle.zip
deploy:
name: Deploy offline website
needs: build
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Setup Action
uses: actions/checkout@v1
- name: Install dependencies
run: sudo apt-get install -y unzip zip
- name: Switch to offline website (gh-pages) branch
run: git checkout gh-pages
- name: Remove previous version website files
run: |
shopt -s extglob
rm -rdfv !("CNAME"|"robots.txt"|"_config.yml")
- name: Download new build from artifact
uses: actions/download-artifact@v1
with:
name: Bundle
- name: Replace bundle with new build
run: |
mv Bundle/bundle.zip bundle.zip
rm -rf Bundle 1>/dev/null 2>&1
- name: Test new bundle
run: zip -T bundle.zip
- name: Extract new bundle
run: |
unzip bundle.zip
mv site/* .
upd=`date +"%Y-%m-%d at %T"`; echo "Website last update: $upd." > README.md
rm -rf site
- name: Commit changes to gh-pages
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add --all .
git commit -a -m "Deploy the generated website via GitHub Actions"
- name: Publish the build to gh-pages
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
- name: Send update to Slack
uses: innocarpe/actions-slack@v1
with:
status: ${{ job.status }}
success_text: 'Offline website deployment: **success**'
failure_text: 'Offline website deployment: **fail**'
cancelled_text: 'Offline website deployment **cancelled**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}