Skip to content

Commit

Permalink
Update icurri_deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
genius00hwan authored Nov 23, 2024
1 parent 53e95e8 commit 4c19580
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions .github/workflows/icurri_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,21 @@ jobs:
needs: ci
name: CD
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ap-northeast-2

steps:
# AWS 인증 구성
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

# Deploy to EC2 (Release Branch)
- name: Deploy to EC2 (Release Branch)
if: github.ref == 'refs/heads/release'
Expand All @@ -95,8 +105,23 @@ jobs:
username: ubuntu
key: ${{ secrets.RELEASE_SSH_KEY }}
script: |
# 컨테이너 중지 및 제거
sudo docker stop $(sudo docker ps -a -q) || true
sudo docker rm $(sudo docker ps -a -q) || true
sudo docker images -q | xargs -r docker rmi || true
sudo docker system prune -af
aws ecr get-login-password --region ap-northeast-2 | sudo
# 사용하지 않는 이미지 및 시스템 정리
sudo docker images -q | xargs -r sudo docker rmi || true
sudo docker system prune -af || true
# ECR 로그인 및 이미지 가져오기
aws ecr get-login-password --region ${{ env.AWS_REGION }} | sudo docker login --username AWS --password-stdin ${{ secrets.ECR_URI }}
sudo docker pull ${{ secrets.ECR_URI }}:${{ github.sha }}
# 새 컨테이너 실행
sudo docker run --name dotflow-dev-repo -d \
-e SPRING_PROFILE=dev \
-e TZ=Asia/Seoul \
-e SERVER=true \
-p 8080:8080 \
${{ secrets.ECR_URI }}:${{ github.sha }}

0 comments on commit 4c19580

Please sign in to comment.