Skip to content

Manual Production Deployment #24

Manual Production Deployment

Manual Production Deployment #24

name: Manual Production Deployment
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy (v0.33.8)'
required: true
jobs:
deploy-to-prod:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.event.inputs.tag }}
- name: Deploy to PROD - AWS EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_AWS_SERVER_HOST }}
username: ${{ secrets.PROD_AWS_SERVER_USERNAME }}
password: ${{ secrets.PROD_AWS_SERVER_PASSWORD }}
port: ${{ secrets.PROD_AWS_SERVER_PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.event.inputs.tag }}
docker stop spot-server-prod || true
docker rm spot-server-prod || true
docker run -d --name spot-server-prod \
-p 8080:8080 \
-p 9292:9292 \
-p 3100:3100 \
-e SPRING_PROFILES_ACTIVE=prod \
-e AWS_REDIS_HOST=${{ secrets.PROD_REDIS_HOST }} \
-e AWS_REDIS_PORT=${{ secrets.PROD_REDIS_PORT }} \
-e SPRING_DATASOURCE_URL=${{ secrets.PROD_DB_URL }} \
-e SPRING_DATASOURCE_USERNAME=${{ secrets.PROD_DB_USERNAME }} \
-e SPRING_DATASOURCE_PASSWORD=${{ secrets.PROD_DB_PASSWORD }} \
-e SPRING_JWT_SECRET=${{ secrets.JWT_SECRET }} \
-e KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }} \
-e OAUTH_KAUTHTOKENURLHOST=${{ secrets.KAUTH_TOKEN_URL_HOST }} \
-e OAUTH_KAUTHUSERURLHOST=${{ secrets.KAUTH_USER_URL_HOST }} \
-e OAUTH_KAKAOCLIENTID=${{ secrets.OAUTH_KAKAOCLIENTID }} \
-e OAUTH_KAKAOAUTHTOKENURLHOST=${{ secrets.KAKAOAUTHTOKENURLHOST }} \
-e OAUTH_KAKAOAUTHUSERURLHOST=${{ secrets.KAKAOAUTHUSERURLHOST }} \
-e OAUTH_KAKAOREDIRECTURL=${{ secrets.KAKAOREDIRECTURL }} \
-e OAUTH_GOOGLECLIENTID=${{ secrets.GOOGLECLIENTID }} \
-e OAUTH_GOOGLECLIENTSECRET=${{ secrets.GOOGLECLIENTSECRET }} \
-e OAUTH_GOOGLEREDIRECTURL=${{ secrets.GOOGLEREDIRECTURL }} \
-e OAUTH_GOOGLEAUTHTOKENURLHOST=${{ secrets.GOOGLEAUTHTOKENURLHOST }} \
-e OAUTH_GOOGLEUSERURLHOST=${{ secrets.GOOGLEUSERURLHOST }} \
-e SPRING_JPA_HIBERNATE_DDL_AUTO=validate \
-e AWS_S3_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }} \
-e AWS_S3_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }} \
-e AWS_S3_BUCKET_NAME=${{ secrets.PROD_AWS_S3_BUCKET_NAME }} \
-e TZ=Asia/Seoul \
-e SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
-e SENTRY_ENABLE_TRACING=true \
-e SENTRY_ENVIRONMENT=prod \
-e LOKI_URL=${{ secrets.LOKI_SERVER_URL }} \
${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.event.inputs.tag }}
docker system prune -af