-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (54 loc) · 1.77 KB
/
ci-cd-develop.yaml
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
name: 'CI/CD DEVELOP'
on:
push:
branches:
- 'develop'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Cache Gradle packages
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: make application.yml
run: |
cd ./api/src/main/resources/
touch ./application.yaml
echo "${{ secrets.YAML_DEV }}" > ./application.yaml
shell: bash
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test
- name: Docker build & Push
run: |
docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_ID }}/backgu:dev .
docker push ${{ secrets.DOCKER_ID }}/backgu:dev
- name: Deploy Images with Docker compose
uses: appleboy/[email protected]
env:
APP: "backgu-dev"
COMPOSE: "/home/ec2-user/compose/docker-compose-dev.yaml"
with:
host: ${{secrets.EC2_DEV_HOST}}
username: ec2-user
key: ${{secrets.EC2_DEV_PRIVATE_KEY}}
port: 22
envs: APP, COMPOSE
script_stop: true
script: |
docker-compose -f $COMPOSE down
docker pull ${{ secrets.DOCKER_ID }}/backgu:dev
docker-compose -f $COMPOSE up -d