Skip to content

[Chore] 도커컴포즈 $$로 변경 #24

[Chore] 도커컴포즈 $$로 변경

[Chore] 도커컴포즈 $$로 변경 #24

Workflow file for this run

name: CI/CD Pipeline for Spring Project
# 트리거 설정: 해당 브랜치로 풀리퀘스트가 머지될 때 트리거
# 현재는 테스트니까 푸쉬로
on:
push:
branches: [ "test/#25-workflow-test" ]
# 나중에 최종으로 사용할 때
# pull_request:
# brances: [develop]
jobs:
build:
# 빌드 작업은 Ubuntu에서 실행
runs-on: ubuntu-latest
steps:
# 1. 소스 코드 체크아웃
- name: Checkout code
uses: actions/checkout@v2
# 2. JDK 설치 (Java 17 기준)
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt' # OpenJDK 사용
java-version: '17'
# 3. Gradle 빌드
- name: Build with Gradle
run: ./gradlew clean build -x test # 테스트를 제외한 Gradle 빌드
# 4. Docker 이미지 빌드
- name: Build Docker image
run: docker build -t fitpet .
# 5. Docker Hub로 Docker 이미지 푸시 (선택적 단계)
- name: Push Docker Image to Docker Hub
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker tag fitpet:latest ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
docker push ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to EC2 via SSH
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
script: |
echo $${{ secrets.DOCKER_PASSWORD }} | docker login -u $${{ secrets.DOCKER_USERNAME }} --password-stdin
docker pull ${{ secrets.DOCKER_USERNAME }}/fitpet:latest
cd /home/ubuntu
docker-compose -f docker-compose.yml up --build -d