Skip to content

#59 서울오빠 파싱 기능추가 (#60) #24

#59 서울오빠 파싱 기능추가 (#60)

#59 서울오빠 파싱 기능추가 (#60) #24

name: deploy_ecr_production
on:
push:
branches:
- main
jobs:
buildAndDeploy:
runs-on: ubuntu-latest
steps:
- name: 프로젝트 로드
uses: actions/checkout@v4
- name: 프로젝트 환경변수 생성
run: |
echo "SERVICE_PORT=${{ vars.SERVICE_PORT }}" >> ./environments/.env.prod
echo 'DATABASE_URL="${{ secrets.DATABASE_URL }}"' >> ./environments/.env.prod
echo 'JWT_ACCESS_TOKEN_SECRET_KEY="${{ secrets.JWT_ACCESS_TOKEN_SECRET_KEY }}"' >> ./environments/.env.prod
echo "JWT_ACCESS_TOKEN_EXPIRES_IN=${{ secrets.JWT_ACCESS_TOKEN_EXPIRES_IN }}" >> ./environments/.env.prod
echo 'JWT_REFRESH_TOKEN_SECRET_KEY="${{ secrets.JWT_REFRESH_TOKEN_SECRET_KEY }}"' >> ./environments/.env.prod
echo "JWT_REFRESH_TOKEN_EXPIRES_IN=${{ secrets.JWT_REFRESH_TOKEN_EXPIRES_IN }}" >> ./environments/.env.prod
echo "IS_HTTP_ONLY_COOKIE=${{ vars.IS_HTTP_ONLY_COOKIE }}" >> ./environments/.env.prod
echo "IS_SECURE_COOKIE=${{ vars.IS_SECURE_COOKIE }}" >> ./environments/.env.prod
echo "COOKIE_PATH=${{ vars.COOKIE_PATH }}" >> ./environments/.env.prod
echo "COOKIE_DOMAIN=${{ vars.COOKIE_DOMAIN }}" >> ./environments/.env.prod
echo "COOKIE_SAME_SITE=${{ vars.COOKIE_SAME_SITE }}" >> ./environments/.env.prod
echo "CORS_ALLOW_ORIGIN=${{ vars.CORS_ALLOW_ORIGIN }}" >> ./environments/.env.prod
echo "REFRESH_TOKEN_EXPIRATION_TIME=${{ secrets.REFRESH_TOKEN_EXPIRATION_TIME }}" >> ./environments/.env.prod
echo "KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }}" >> ./environments/.env.prod
echo 'KAKAO_CLIENT_SECRET="${{ secrets.KAKAO_CLIENT_SECRET }}"' >> ./environments/.env.prod
echo 'KAKAO_REDIRECT_URL="${{ vars.KAKAO_REDIRECT_URL }}"' >> ./environments/.env.prod
echo 'NAVER_CLIENT_ID="${{ secrets.NAVER_CLIENT_ID }}"' >> ./environments/.env.prod
echo 'NAVER_CLIENT_SECRET="${{ secrets.NAVER_CLIENT_SECRET }}"' >> ./environments/.env.prod
echo 'NODE_ENV="prod"' >> ./environments/.env.prod
- name: PNPM 사용
uses: pnpm/action-setup@v2
with:
version: latest
- name: NodeJS 설정
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: 의존성 설치
run: pnpm i
- name: Prisma Deploy
run: pnpm prisma:deploy:prod
- name: AWS 로그인
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: ECR 로그인
id: ecr-login-info
uses: aws-actions/amazon-ecr-login@v2
- name: 이미지 빌드 및 ECR 푸시
id: build-image-info
env:
ECR_REGISTRY: ${{ steps.ecr-login-info.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg NODE_ENV=prod .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: ECS Task 개정
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ vars.ECS_TASK_DEFINITION }}
container-name: ${{ vars.CONTAINER_NAME }}
image: ${{ steps.build-image-info.outputs.image }}
- name: Task 배포
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ vars.ECS_SERVICE }}
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true