Skip to content

Commit

Permalink
[BE] refactor: aws iam 인증 수정 (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: EunJiJung <[email protected]>
  • Loading branch information
bianbbc87 committed Feb 9, 2025
1 parent ff799f6 commit 96974bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
17 changes: 9 additions & 8 deletions .github/actions/ecr-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ runs:
echo "Build & Push completed!"
- name: EC2에서 ECR에 로그인하기
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
Expand All @@ -93,7 +93,7 @@ runs:
aws ecr get-login-password --region ${{ inputs.aws_region }} | sudo docker login --username AWS --password-stdin ${{ inputs.ecr_uri }}
- name: 기존 EC2에서 실행중인 컨테이너 종료
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
Expand All @@ -102,7 +102,7 @@ runs:
sudo docker ps -q | xargs -r docker stop
- name: 기존 EC2에 존재하는 모든 컨테이너 삭제
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
Expand All @@ -111,7 +111,7 @@ runs:
sudo docker ps -asq | xargs -r docker rm
- name: 기존 EC2에 저장되어있는 이미지 삭제
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
Expand All @@ -120,7 +120,7 @@ runs:
sudo docker images -q | xargs -r docker rmi
- name: EC2에서 도커에서 사용하지 않는 자원 삭제처리
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
Expand All @@ -129,7 +129,7 @@ runs:
sudo docker system prune -af
- name: EC2에서 도커 이미지를 가져오기
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
Expand All @@ -138,16 +138,17 @@ runs:
sudo docker pull ${{ inputs.ecr_uri }}/${{ inputs.namespace }}/${{ inputs.ecr_repo }}:${{ github.sha }}
- name: ECR에서 불러온 이미지를 도커에서 실행
uses: appleboy/ssh-action@master
uses: actions/checkout@v3
with:
host: ${{ inputs.ec2_ip }}
username: ${{ inputs.ec2_username }}
key: ${{ inputs.ec2_ssh_key }}
script: |
sudo docker stop ${{ inputs.container_name }} || true
sudo docker rm ${{ inputs.container_name }} || true
if [ "${{ inputs.container_port }}" -eq "0" ]; then
if [ "$((inputs.container_port))" -eq 0 ]; then
sudo docker run -d --name ${{ inputs.container_name }} ${{ inputs.ECR_URI }}:${{ github.sha }}
else
sudo docker run -d --name ${{ inputs.container_name }} -p ${{ inputs.container_port }}:${{ inputs.container_port }} ${{ inputs.ECR_URI }}:${{ github.sha }}
fi
12 changes: 6 additions & 6 deletions .github/workflows/be-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ jobs:
ec2_username: ${{ secrets.AWS_EC2_USERNAME }}
ec2_ssh_key: ${{ secrets.AWS_SERVICE_SSH_KEY }}
container_name: "user-container"
container_port: "0"
container_port: 0

build-service-chat:
needs: check-folder-change
Expand All @@ -296,7 +296,7 @@ jobs:
ec2_username: ${{ secrets.AWS_EC2_USERNAME }}
ec2_ssh_key: ${{ secrets.AWS_CHAT_SSH_KEY }}
container_name: "chat-container"
container_port: "0"
container_port: 0

build-service-state:
needs: check-folder-change
Expand All @@ -321,7 +321,7 @@ jobs:
ec2_username: ${{ secrets.AWS_EC2_USERNAME }}
ec2_ssh_key: ${{ secrets.AWS_SERVICE_SSH_KEY }}
container_name: "state-container"
container_port: "0"
container_port: 0

build-service-guild:
needs: check-folder-change
Expand All @@ -346,7 +346,7 @@ jobs:
ec2_username: ${{ secrets.AWS_EC2_USERNAME }}
ec2_ssh_key: ${{ secrets.AWS_SERVICE_SSH_KEY }}
container_name: "guild-container"
container_port: "0"
container_port: 0

build-service-notification:
needs: check-folder-change
Expand All @@ -371,7 +371,7 @@ jobs:
ec2_username: ${{ secrets.AWS_EC2_USERNAME }}
ec2_ssh_key: ${{ secrets.AWS_SERVICE_SSH_KEY }}
container_name: "notification-container"
container_port: "0"
container_port: 0

build-service-signaling:
needs: check-folder-change
Expand All @@ -396,4 +396,4 @@ jobs:
ec2_username: ${{ secrets.AWS_EC2_USERNAME }}
ec2_ssh_key: ${{ secrets.AWS_SERVICE_SSH_KEY }}
container_name: "signaling-container"
container_port: "0"
container_port: 0

0 comments on commit 96974bc

Please sign in to comment.