-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (77 loc) · 3.14 KB
/
deployment.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
name: Deployment
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
deploy-frontend:
name: Deploy Frontend
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Install dependencies
run: yarn
working-directory: ./website
- name: Build
run: yarn build
working-directory: ./website
env:
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
OAUTH_REDIRECT_URI: ${{ secrets.OAUTH_REDIRECT_URI }}
DB_URL: ${{ secrets.DB_URL }}
- name: Remove old files from server
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "rm -rf ${{ secrets.SSH_SERVER_FRONTEND_PATH }}*"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
- name: Deploy frontend to server
uses: wlixcc/[email protected]
with:
username: ${{ secrets.SSH_SERVER_USERNAME }}
server: ${{ secrets.SSH_SERVER_NAME }}
port: ${{ secrets.SSH_SERVER_PORT }}
ssh_private_key: ${{ secrets.DEPLOY_KEY }}
local_path: "./website/dist/*"
remote_path: ${{ secrets.SSH_SERVER_FRONTEND_PATH }}
deploy-backend:
name: Deploy Backend
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Remove old files from server
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "rm -rf ${{ secrets.SSH_SERVER_BACKEND_PATH }}*"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
- name: Deploy backend to server
uses: wlixcc/[email protected]
with:
username: ${{ secrets.SSH_SERVER_USERNAME }}
server: ${{ secrets.SSH_SERVER_NAME }}
port: ${{ secrets.SSH_SERVER_PORT }}
ssh_private_key: ${{ secrets.DEPLOY_KEY }}
local_path: "./backend/*"
remote_path: ${{ secrets.SSH_SERVER_BACKEND_PATH }}
- name: Create .env file
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "cd ${{ secrets.SSH_SERVER_BACKEND_PATH }} && echo 'OAUTH_CLIENT_ID="${{ secrets.OAUTH_CLIENT_ID }}"\nOAUTH_CLIENT_SECRET="${{ secrets.OAUTH_CLIENT_SECRET }}"\nOAUTH_REDIRECT_URI="${{ secrets.OAUTH_REDIRECT_URI }}"\nDB_URL="${{ secrets.DB_URL }}"' > .env"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
- name: Run backend
run: |
ssh -p ${{ secrets.SSH_SERVER_PORT }} ${{ secrets.SSH_SERVER_USERNAME }}@${{ secrets.SSH_SERVER_NAME }} "cd ${{ secrets.SSH_SERVER_BACKEND_PATH }} && screen -S fitplanconnect-backend -X quit && screen -S fitplanconnect-backend -d -m bun run dev"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}