-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (58 loc) · 3 KB
/
manual-prod-deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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 \
-e SPRING_PROFILES_ACTIVE=dev \
-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 OAUTH_CLIENTID=${{ secrets.KAKAO_CLIENT_ID }} \
-e OAUTH_KAUTHTOKENURLHOST=${{ secrets.KAUTH_TOKEN_URL_HOST }} \
-e OAUTH_KAUTHUSERURLHOST=${{ secrets.KAUTH_USER_URL_HOST }} \
-e SPRING_JPA_HIBERNATE_DDL_AUTO=validate \
-e NCP_OBJECT_STORAGE_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }} \
-e NCP_OBJECT_STORAGE_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }} \
-e TZ=Asia/Seoul \
-e SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
-e SENTRY_ENABLE_TRACING=true \
-e SENTRY_ENVIRONMENT=prod \
${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.event.inputs.tag }}
docker system prune -af