-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (97 loc) · 3.04 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Docker CI/CD
on:
push:
branches:
- deploy
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
CI: false
steps:
- name: 🗃️ Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Check out source code
uses: actions/checkout@v2
- name: 📦️ Setup JDK 11.0.12
uses: actions/setup-java@v1
with:
java-version: 11.0.12
- name: 💾 Cache Gradle & Spring
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: make application-db.properties
run: |
cd ./src/main/resources
touch ./application-db.properties
echo "${{ secrets.DB_PROPERTIES }}" > ./application-db.properties
shell: bash
- name: make application-mail.properties
run: |
cd ./src/main/resources
touch ./application-mail.properties
echo "${{ secrets.MAIL_PROPERTIES }}" > ./application-mail.properties
shell: bash
- name: 🔧 Build Spring server
run: |
chmod +x ./gradlew
./gradlew clean build -x test
- name: 📦️ Setup NodeJS 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install modules
working-directory: ./univcert-web
run: |
ls -al
pwd
whoami
npm install
- name: 🔧 npm run build
working-directory: ./univcert-web
run: npm run build
- name: Deploy Prod use SCP [Spring]
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST_DEV }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./build/libs/*.jar"
target: "/home/ec2-user/deploy"
strip_components: 2
- name: Deploy Prod use SCP [React]
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST_DEV }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./univcert-web/build/*"
target: "/home/ec2-user/deploy/front"
strip_components: 2
- name: Execute Server/Front Init Script
uses: appleboy/ssh-action@master
id: deploy-prod
with:
host: ${{ secrets.HOST_DEV }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
port: 22
envs: GITHUB_SHA
script: |
cd deploy
docker container stop univcert
docker container stop univcert-web
docker build -t univcert-docker .
docker run -d --rm -p 8080:8080 --name univcert univcert-docker
cd front
docker build -t univcert-web .
docker run -d --rm -it -p 3000:3000 --name univcert-web univcert-web