Skip to content

Workflow file for this run

name: Deploy to AWS EC2
on:
push:
branches:
- develop
release:
types: [published]
jobs:
build:
runs-on: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
environment:
name: ${{ github.event_name == 'release' && 'production' || 'development' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set .ENV file
run: |
echo "API_HOST=${{ vars.API_HOST }}" >> .env
echo "NODE_ENV=${{ vars.NODE_ENV }}" >> .env
echo "NEXT_PUBLIC_GA_ID=${{ secrets.NEXT_PUBLIC_GA_ID }}" >> .env
echo "NEXT_PUBLIC_GTM_ID=${{ secrets.NEXT_PUBLIC_GTM_ID }}" >> .env
echo "AUTH_KAKAO_ID=${{secrets.AUTH_KAKAO_ID}}" >> .env
echo "AUTH_KAKAO_SECRET=${{secrets.AUTH_KAKAO_SECRET}}" >> .env
echo "AUTH_SECRET=${{secrets.AUTH_SECRET}}" >> .env
echo "NEXTAUTH_URL=${{vars.NEXTAUTH_URL}}" >> .env
echo "NEXT_PUBLIC_KAKAO_API_KEY=${{ secrets.NEXT_PUBLIC_KAKAO_API_KEY }}" >> .env
- name: Build docker image
run: docker build -t ${{ vars.DOCKER_IMAGE }} .
- name: Login to DockerHub
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Push to DockerHub
run: docker push ${{ vars.DOCKER_IMAGE }}
deploy:
needs: build
runs-on: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
environment:
name: ${{ github.event_name == 'release' && 'production' || 'development' }}
steps:
- name: Pull from DockerHub
run: docker pull ${{ vars.DOCKER_IMAGE }}
- name: Delete existing container
run: docker rm -f polabo-fe || true
- name: Run container
run: docker run -d -p 3000:3000 --name polabo-fe ${{ vars.DOCKER_IMAGE }}