-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (65 loc) · 2.13 KB
/
Copy pathdeploy.yml
File metadata and controls
77 lines (65 loc) · 2.13 KB
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
name: Deploy to 247 Server
on:
push:
branches:
- main
paths:
- 'onecard-web/**'
- 'onecard-api/**'
- 'onecard-app/**'
- 'onecard-pushserver/**'
jobs:
deploy:
name: Deploy ${{ matrix.name }}
runs-on: self-hosted
strategy:
matrix:
include:
- name: onecard-web
path: onecard-web
host_port: 9413
container_port: 8000
env_secret: ENV_FILE_WEB
- name: onecard-api
path: onecard-api
host_port: 9414
container_port: 8001
env_secret: ENV_FILE_API
- name: onecard-app
path: onecard-app
host_port: 9415
container_port: 8002
env_secret: ENV_FILE_APP
- name: onecard-pushserver
path: onecard-pushserver
host_port: 9416
container_port: 5000
env_secret: ENV_FILE_NOTI
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Sync project files to target directory
run: |
rsync -av --delete --exclude '.git' \
${{ github.workspace }}/ \
/home/ubuntu/OSS-onecard/
- name: Create .env file from secrets
run: |
echo "${{ secrets[matrix.env_secret] }}" > /home/ubuntu/OSS-onecard/${{ matrix.path }}/.env
- name: Deploy to Remote Server
run: |
set -e
cd /home/ubuntu/OSS-onecard/${{ matrix.path }}
echo "Building Docker Image for ${{ matrix.name }}..."
docker build -t ${{ matrix.name }} .
echo "Removing old container if exists..."
docker stop ${{ matrix.name }} || true
docker rm ${{ matrix.name }} || true
docker network create onecard-net || true
echo "Running new container for ${{ matrix.name }}..."
docker run -d \
--name ${{ matrix.name }} \
--network onecard-net \
--env-file .env \
-p ${{ matrix.host_port }}:${{ matrix.container_port }} \
${{ matrix.name }}