-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (84 loc) · 2.82 KB
/
deploy-dev.yml
File metadata and controls
101 lines (84 loc) · 2.82 KB
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
name: Deploy Dev
on:
workflow_run:
workflows: [ "CI" ]
branches: [ dev ]
types: [ completed ]
permissions:
contents: read
env:
IMAGE_REPOSITORY: ${{ secrets.DOCKERHUB_REPOSITORY }}
jobs:
build:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'dev'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build JAR
run: ./gradlew clean build -x test --no-daemon
# ARM Docker Build 설정
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push dev image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/arm64 # t4g small 배포를 위한 arm platform 설정
push: true
tags: |
${{ env.IMAGE_REPOSITORY }}:dev-latest
${{ env.IMAGE_REPOSITORY }}:dev-${{ github.event.workflow_run.head_sha }}
deploy:
needs: build
runs-on: ubuntu-latest
if: needs.build.result == 'success'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
# /infra/dev 하위 파일 EC2로 복사
- name: Upload deployment files to EC2
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ${{ secrets.DEV_EC2_USER }}
key: ${{ secrets.DEV_EC2_SSH_KEY }}
source: "infra/dev"
target: "${{ secrets.DEV_DEPLOY_DIR }}"
- name: Deploy to dev server
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ${{ secrets.DEV_EC2_USER }}
key: ${{ secrets.DEV_EC2_SSH_KEY }}
script: |
set -euo pipefail
DEPLOY_DIR="${{ secrets.DEV_DEPLOY_DIR }}/infra/dev"
chmod +x "$DEPLOY_DIR/scripts/deploy.sh"
APP_IMAGE="${{ env.IMAGE_REPOSITORY }}:dev-${{ github.event.workflow_run.head_sha }}" \
DOMAIN="${{ secrets.DEV_DOMAIN }}" \
DEPLOY_DIR="$DEPLOY_DIR" \
"$DEPLOY_DIR/scripts/deploy.sh"