Skip to content

Commit

Permalink
[fix] 현재버전 환경변수 사용으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wndlthsk committed Nov 7, 2024
1 parent ebdb234 commit d8d4179
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
# 다음 배포 버전을 결정
- name: Set next version
run: |
if [[ "$CURRENT_VERSION" == "blue" ]]; then
if [[ "${{ env.current_version }}" == "blue" ]]; then
NEXT_VERSION="green"
PORT=8081
else
Expand All @@ -100,9 +100,9 @@ jobs:
# 기존의 동일한 컨테이너를 중지 (블루/그린 중 다음 배포 타겟에 해당하는 컨테이너)
- name: Stop current docker container
run: |
echo "Stopping container inplace-${{ env.NEXT_VERSION }}"
sudo docker stop inplace-${{ env.NEXT_VERSION }} || true
sudo docker rm inplace-${{ env.NEXT_VERSION }} || true
echo "Stopping container inplace-${{ env.next_version }}"
sudo docker stop inplace-${{ env.next_version }} || true
sudo docker rm inplace-${{ env.next_version }} || true
# .env 파일 생성
- name: Create .env file
Expand All @@ -113,23 +113,22 @@ jobs:
# 다음 버전으로 새 컨테이너를 실행
- name: Run New Container on Next Version
run: |
echo "Running new container inplace-${{ env.NEXT_VERSION }}"
sudo docker run --name "inplace-${{ env.NEXT_VERSION }}" --rm -d -p ${{ env.port }}:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace
echo "Running new container inplace-${{ env.next_version }}"
sudo docker run --name "inplace-${{ env.next_version }}" --rm -d -p ${{ env.port }}:8080 --env-file .env ${{ secrets.DOCKERHUB_USERNAME }}/inplace
# 로드 밸런서 타겟 그룹을 업데이트하여 트래픽을 새 컨테이너로 전환합니다.
- name: Update Load Balancer Target Group
run: |
TARGET_GROUP_ARN_BLUE="${{ secrets.TARGET_GROUP_ARN_8080 }}"
TARGET_GROUP_ARN_GREEN="${{ secrets.TARGET_GROUP_ARN_8081 }}"
if [[ "${{ env.NEXT_VERSION }}" == "blue" ]]; then
if [[ "${{ env.next_version }}" == "blue" ]]; then
aws elbv2 modify-listener --listener-arn ${{ secrets.LISTENER_ARN_443 }} --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN_BLUE
else
aws elbv2 modify-listener --listener-arn ${{ secrets.LISTENER_ARN_443 }} --default-actions Type=forward,TargetGroupArn=$TARGET_GROUP_ARN_GREEN
fi
# 이전 컨테이너 정리
- name: Remove previous docker container
if: env.CURRENT_VERSION != 'none'
run: |
if [[ "${{ env.CURRENT_VERSION }}" != "none" ]]; then
echo "Removing previous container inplace-${{ env.CURRENT_VERSION }}"
Expand Down

0 comments on commit d8d4179

Please sign in to comment.