Update rankit-multiaz-cicd.yml #48
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: develop branch bluegreen deployment | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
# 1. JDK 17 설정 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 2. Gradle 설정 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | |
# 3. Jar 파일 빌드 (테스트 제외) | |
- name: Build with Gradle Wrapper | |
run: ./gradlew -x test bootJar | |
# 4. Docker Buildx 설정 | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v1 | |
# 5. Docker 로그인 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
# 6. Docker 이미지 빌드 및 푸시 | |
- name: Build and push Docker image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build # build 작업이 완료되어야 실행 | |
permissions: | |
contents: read | |
steps: | |
# 1. EC2 SSH 접속을 위한 키 등록 | |
- name: Set up SSH key | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.API_RANKIT_PEM }} | |
# 2. EC2에 blue green 무중단 배포를 위한 스크립트 실행 | |
#- name: Run dPlanner.sh for CICD and switch blue-green container | |
# run: | | |
# ssh -o StrictHostKeyChecking=no ec2-user@${{ secrets.EC2_HOST }} << 'EOF' | |
# cd bluegreen/ | |
# chmod +x dplanner.sh # 만약 실행 권한이 없다면 추가 | |
# ./dplanner.sh # 스크립트 실행 | |
# EOF |