Manual Production Deployment #34
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: 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 SPRING_SERVLET_MULTIPART_MAX-FILE-SIZE=30MB \ | |
-e SPRING_SERVLET_MULTIPART_MAX-REQUEST-SIZE=30MB \ | |
-e SPRING_JPA_HIBERNATE_DDL_AUTO=validate \ | |
-e TZ=Asia/Seoul \ | |
-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 |