-
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (75 loc) · 2.18 KB
/
deploy.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
name: "Deploy books"
on:
push:
branches:
- master
workflow_dispatch:
pull_request:
env:
OUT_DIR: "${{ github.workspace }}/out"
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Prepare books
run: |
for dir in *; do
[ -d "${dir}" ] || continue;
[ -x "${dir}/scripts/pre-build.sh" ] || continue;
bash "${dir}/scripts/pre-build.sh";
done
- name: Create out dir
run: mkdir -p $OUT_DIR
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.18'
- name: Build books
run: |
for dir in *; do
[ -d "${dir}" ] || continue;
[ -d "${dir}/${dir}-ru" ] || continue;
pushd "${dir}/${dir}-ru";
mdbook build -d "${OUT_DIR}/${dir}" .;
popd;
done
- uses: actions/upload-artifact@v2
with:
name: books-${{ github.sha }}
path: "${{ env.OUT_DIR }}"
deploy:
needs: build
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/download-artifact@v2
with:
name: books-${{ github.sha }}
path: ${{ env.OUT_DIR }}
- name: Install key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: "dump"
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
- name: Packing books
run: tar -caf .books.tar.gz -C ${{ github.workspace }} out
- name: Upload to server
run: scp .books.tar.gz "${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:"
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
rm -rf out
tar -xaf .books.tar.gz
/home/${{ secrets.DEPLOY_USER }}/deploy-books.sh