-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.63 KB
/
github-actions.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
## https://zzang9ha.tistory.com/404
name: Polzzak CI/CD
on:
push:
branches:
- develop
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
## jdk setting
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
## [DEV] create application.yml
- name: make secret.yml
if: contains(github.ref, 'develop')
run: |
cd ./src/main/resources
echo "${{ secrets.SECRET_SETTINGS }}" | base64 -d >> ./application-secret.yml
## gradle build
- name: Build with Gradle
run: ./gradlew clean build
## docker build & push to develop
- name: Docker build & push to dev
if: contains(github.ref, 'develop')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_REPO }}/polzzak-dev .
docker push ${{ secrets.DOCKER_REPO }}/polzzak-dev
## deploy to develop
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'develop')
with:
host: ${{ secrets.HOST_DEV }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: 22
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}/polzzak-dev
docker run -d -p 8080:8080 ${{ secrets.DOCKER_REPO }}/polzzak-dev
docker image prune -f