chore: readme 업데이트 #69
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
name: CI/CD | |
on: | |
push: | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- run: yarn install | |
- run: npx @nestjs/cli build | |
- run: yarn run lint | |
build: | |
needs: CI | |
if: github.ref == 'refs/heads/master' | |
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 | |
if: github.ref == 'refs/heads/master' | |
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 |