-
Notifications
You must be signed in to change notification settings - Fork 4
66 lines (51 loc) · 2.27 KB
/
build.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
name: Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
services:
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Nuxt build
run: |
npm install yarn -g
yarn install
yarn build
env:
CI: true
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
- name: Deploy to servers
run: |
mkdir ~/.ssh
echo "$DEPLOYMENT_KEY" > ~/.ssh/github-deployment
chmod 700 ~/.ssh
chmod 600 ~/.ssh/github-deployment
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST rm -rf /srv/www-publish
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST mkdir /srv/www-publish
tar --create --file=build.tar.gz --exclude=build.tar.gz --warning=none --ignore-failed-read --verbose --gzip . || true
scp -rp -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment build.tar.gz $SERVER_USER@$SERVER_HOST:/srv/www-publish/
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST "cd /srv/www-publish && tar --extract --gzip --file=build.tar.gz && rm build.tar.gz"
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST rm -rf /srv/www-backup
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST mv /srv/www /srv/www-backup || true
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST mv /srv/www-publish /srv/www
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST "chown -R www-data:www-data /srv/www"
ssh -o "StrictHostKeyChecking no" -i ~/.ssh/github-deployment $SERVER_USER@$SERVER_HOST service updoot restart
env:
DEPLOYMENT_KEY: ${{ secrets.DEPLOYMENT_KEY }}
SERVER_HOST: ${{ secrets.SERVER_HOST }}
SERVER_USER: ${{ secrets.SERVER_USER }}