-
Notifications
You must be signed in to change notification settings - Fork 5
70 lines (60 loc) · 2.19 KB
/
local-prod.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
name: Build Docs
on:
push:
branches:
- master
jobs:
build:
env:
DEPLOY_USER: gh-dcs-deploy
DEPLOY_HOST: lordvesel.win
RELEASE_DIR: /var/www/dcs-docs/prod/releases/${{ github.ref }}/${{ github.run_number }}
RELEASES_DIR: /var/www/dcs-docs/prod/releases/
CURRENT_DIR: /var/www/dcs-docs/prod/current
runs-on:
- self-hosted
- dcs
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: CSS
run: |
export T=$(date +%s)
export CSS=css/materal-add-${T}.css
for L in ru en
do
yq -i '.extra_css[0] = strenv(CSS)' $L/mkdocs.yml
mv $L/docs/css/materal-add.css $L/docs/$CSS
done
- name: Build mkdocs
run: |
docker run -i --rm -e CI -e COMMITERS_TOKEN=${{secrets.COMMITERS_TOKEN}} -e GOOGLE_ANAL=${{secrets.GOOGLE_ANAL}} -v $PWD:/build -w /build python:3.10-alpine sh -c 'apk add git gcc linux-headers musl-dev && \
git config --global --add safe.directory /build && \
cd ru && pip install -r requirements.txt && \
mkdocs build && \
cd ../en && mkdocs build && \
chown -R 1004:1004 ../'
- name: Deploy
run: |
[[ -d ${{env.RELEASE_DIR}}/ru ]] || mkdir -p ${{env.RELEASE_DIR}}/ru
[[ -d ${{env.RELEASE_DIR}}/en ]] || mkdir -p ${{env.RELEASE_DIR}}/en
rsync -a ru/site/ ${{env.RELEASE_DIR}}/ru/
rsync -a en/site/ ${{env.RELEASE_DIR}}/en/
- name: Switch release
run: |
ln -sfn ${{env.RELEASE_DIR}} ${{env.CURRENT_DIR}}
for R in `ls ${{env.RELEASES_DIR}}/${{ github.ref }} | sort -n | head -n -2`
do rm -rf ${{env.RELEASES_DIR}}/${{ github.ref }}/$R
done
- name: Status Success Notification
if: ${{ success() }}
run: |
ntfy -b telegram send "⚡ GITHUB: Successfuly deployed PROD. Check out
https://dcs-docs.lordvesel.win/ru/
https://dcs-docs.lordvesel.win/en/"
- name: Status Fail Notification
if: ${{ failure() }}
run: |
ntfy -b telegram send "💩 GITHUB: Deploy PROD failed."