Skip to content

chore: 데이터베이스 날아간 김에 migration 하나로 통합 #23

chore: 데이터베이스 날아간 김에 migration 하나로 통합

chore: 데이터베이스 날아간 김에 migration 하나로 통합 #23

Workflow file for this run

name: CI/CD
on:
push:
branches: [master]
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- 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: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
run: |
docker build -t interstellar_repo .
docker tag interstellar_repo:latest ${{secrets.ECR_IMAGE_URI}}:latest
docker push ${{secrets.ECR_IMAGE_URI}}:latest
deploy:
needs: build
name: CD
runs-on: self-hosted
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: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
run: |
aws ecr get-login-password --region ap-northeast-2 | sudo docker login --username AWS --password-stdin ${{secrets.AWS_ACCOUNT_ID}}.dkr.ecr.ap-northeast-2.amazonaws.com
- name: Pull image from Amazon ECR and restart container
run: |
sudo docker pull ${{secrets.ECR_IMAGE_URI}}:latest
sudo docker stop interstellar && sudo docker rm interstellar
sudo docker run -d --env-file ~/.env --name interstellar -p 3000:3000 --restart unless-stopped ${{secrets.ECR_IMAGE_URI}}:latest