Skip to content

fix: trend컴포넌트 hydrate에러 수정 (#81) #85

fix: trend컴포넌트 hydrate에러 수정 (#81)

fix: trend컴포넌트 hydrate에러 수정 (#81) #85

Workflow file for this run

name: Deploy to Amazon EC2
on:
push:
branches:
- develop
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
env:
AWS_REGION: ap-northeast-2
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Cleanup Unused ECR Images
id: cleanup-images
env:
ECR_REPOSITORY: linker
IMAGE_TAG: ${{ github.sha }}
run: |
aws ecr batch-delete-image --repository-name $ECR_REPOSITORY --image-ids imageTag=$IMAGE_TAG
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: linker
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
docker rmi $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Deploy to EC2
env:
IMAGE_TAG: ${{ github.sha }}
EC2_IP: ${{ secrets.EC2_IP_ADDRESS }}
run: |
echo "${{ secrets.EC2_SSH_PRIVATE_KEY }}" > private_key.pem
chmod 600 private_key.pem
ssh -v -i private_key.pem -o StrictHostKeyChecking=no ubuntu@$EC2_IP "
aws ecr get-login-password --region ap-northeast-2 |
sudo docker login --username AWS --password-stdin 903755389667.dkr.ecr.ap-northeast-2.amazonaws.com/linker &&
sudo docker container rm -f $(sudo docker container ls -a --quiet)
sudo docker rmi $(sudo docker images -q) -f
sudo docker image pull 903755389667.dkr.ecr.ap-northeast-2.amazonaws.com/linker:$IMAGE_TAG &&
sudo docker container run --name linker --restart=always -d -p 3000:3000 903755389667.dkr.ecr.ap-northeast-2.amazonaws.com/linker:$IMAGE_TAG"