-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 1.76 KB
/
cd-dev.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
name: cd-dev
on:
push:
branches: [ "dev" ]
jobs:
deploy-to-ec2:
environment: dev
runs-on: ubuntu-latest
steps:
- name: Github Repository Checkout
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.ACCESS_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
- name: Docker Hub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Docker Image Build and Push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_HUB_REPOSITORY }}
- name: Copy Deployment Files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_INSTANCE_HOST }}
username: ${{ secrets.EC2_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_INSTANCE_PRIVATE_KEY }}
source: './deploy/dev/*'
target: '~/pickple/deploy'
strip_components: 1
- name: Docker Container Run
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_INSTANCE_HOST }}
username: ${{ secrets.EC2_INSTANCE_USERNAME }}
key: ${{ secrets.EC2_INSTANCE_PRIVATE_KEY }}
script: |
docker pull ${{ secrets.DOCKER_HUB_REPOSITORY }}
cd ~/pickple/deploy/dev
docker-compose -p pickple-dev down
docker-compose -p pickple-dev up -d
docker image prune -f