-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (71 loc) · 2.54 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
name: Deploy
on:
push:
branches:
- main
jobs:
deployment:
runs-on: ubuntu-latest
environment: Production
steps:
- name: Get current time for Folder
uses: josStorer/[email protected]
id: current-time
with:
format: YYYYMMDDHHMMSS
- name: Get current time for Cleanup
uses: josStorer/[email protected]
id: current-time-cleanup
with:
format: YYYYMM
- uses: actions/checkout@v1
- uses: actions/setup-node@v3
with:
node-version: 12
- run: npm ci
- name: Build App
run: npm run build
env:
CI: false
REACT_APP_RAFFLER_SERVER: 'wss://raffle-server.amsterdamphp.nl'
REACT_APP_RAFFLER_CLIENT_URL: 'raffles.amsterdamphp.nl'
PUBLIC_URL: "/"
- name: Copy Server Files to upload
run: cp -Rf ./server ./build/
- name: Publish to Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "./build/"
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
TARGET: ${{ secrets.DEPLOY_RELEASES_FOLDER }}/${{ steps.current-time.outputs.formattedTime }}
- name: Deploy on Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
key: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
username: ${{ secrets.DEPLOY_USER }}
script: |
rm -Rf ${{ secrets.DEPLOY_CURRENT_PATH }}
ln -sf ${{ secrets.DEPLOY_RELEASES_FOLDER }}/${{ steps.current-time.outputs.formattedTime }} ${{ secrets.DEPLOY_CURRENT_PATH }}
- name: Validate Host Conf
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
key: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
username: ${{ secrets.DEPLOY_USER }}
script: |
rm -Rf /etc/nginx/sites-enabled/raffle-client
ln -sf ${{ secrets.DEPLOY_CURRENT_PATH }}/server/raffle-client.nginx /etc/nginx/sites-enabled/raffle-client
service nginx reload
- name: Server Cleanup
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
key: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
username: ${{ secrets.DEPLOY_USER }}
script: |
cd ${{ secrets.DEPLOY_RELEASES_FOLDER }}
find . -maxdepth 1 -mindepth 1 -type d -a ! -regex '.*${{ steps.current-time-cleanup.outputs.formattedTime }}.*' -exec rm -Rf {} \+