-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (74 loc) · 2.46 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
on:
push:
branches:
- main
pull_request:
branches:
- main
name: Deploy Spring boot to Amazon EC2
env:
PROJECT_NAME: board
permissions:
contents: read
jobs:
deploy:
name: SIMPLE-BOARD DEPLOY
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Set Yaml
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application-prod.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USER_NAME }}
spring.datasource.password: ${{ secrets.DB_PASSWORD }}
cloud.aws.s3.bucket: ${{ secrets.BUCKET_NAME }}
cloud.aws.region.static: ${{ secrets.AWS_REGION }}
cloud.aws.credentials.access-key: ${{ secrets.S3_ACCESS }}
cloud.aws.credentials.secret-key: ${{ secrets.S3_SECRET }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
shell: bash
- name: Build with Gradle
run: ./gradlew build
shell: bash
# Docker 이미지 Build
- name: docker image build WAS-01
run: docker build -t haechansomg/simple-board:was01 -f ./dockerFile-was01 .
# - name: docker image build WAS-02
# run: docker build -t haechansomg/simple-board2:was02 -f ./dockerFile-was02 .
# DockerHub Login
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Docker Hub push
- name: docker Hub push WAS-01
run: docker push haechansomg/simple-board:was01
# # Docker Hub push
# - name: docker Hub push WAS-02
# run: docker push haechansomg/simple-board2:was02
- name: Deploy to server
uses: appleboy/[email protected]
id: deploy
env:
COMPOSE: "/home/ubuntu/compose/docker-compose.yml"
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
envs: COMPOSE
port: 22
script: |
sudo docker-compose -f $COMPOSE down --rmi all
sudo docker pull haechansomg/simple-board:was01
sudo docker-compose -f $COMPOSE up -d
sudo docker image prune -f