-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from SWM-NM/dev
🐛 [FIX] ECR push 오류 해결 #220
- Loading branch information
Showing
1 changed file
with
8 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,10 @@ on: | |
env: | ||
AWS_REGION: ap-northeast-2 | ||
ECR_REPOSITORY: morandi-backend | ||
ECR_REGISTRY: public.ecr.aws/s7z8j0e6/morandi-backend | ||
EC2_HOST: 3.38.102.140 | ||
GITHUB_SHA: ${{ github.sha }} | ||
|
||
|
||
permissions: | ||
contents: read | ||
|
@@ -51,11 +54,11 @@ jobs: | |
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build and Push Docker image | ||
uses: docker/build-push-action@v2 | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.ECR_REPOSITORY }}:${{ github.sha }} | ||
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{env.GITHUB_SHA}} | ||
|
||
- name: appleboy SSH and Deploy to EC2 | ||
uses: appleboy/[email protected] # ssh 접속하는 오픈소스 | ||
|
@@ -64,13 +67,14 @@ jobs: | |
username: ubuntu | ||
key: ${{ secrets.SSH_SECRET_ACCESS_KEY }} | ||
port: 22 | ||
script: | | ||
script: | | ||
export TAG=${{env.GITHUB_SHA}} | ||
cd /home/ubuntu/morandi-backend | ||
docker-compose down | ||
|
||
# ECR에서 이미지 가져오기 | ||
docker pull ${ECR_REPOSITORY}:latest | ||
docker pull ${ECR_REPOSITORY}:${TAG} | ||
|
||
docker-compose up -d | ||
|
||
|