Skip to content

Merge pull request #131 from dnd-side-project/fix/redis-host #69

Merge pull request #131 from dnd-side-project/fix/redis-host

Merge pull request #131 from dnd-side-project/fix/redis-host #69

Workflow file for this run

name: Blooming Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Create firebase directory
run: mkdir ./client/src/main/resources/firebase/
- name: Create Firebase Admin SDK JSON file
id: create-json
uses: jsdaniell/[email protected]
with:
name: "blooming-firebase-adminsdk.json"
json: ${{ secrets.FIREBASE_ADMIN_SDK_JSON }}
dir: './client/src/main/resources/firebase/'
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/blooming-server:latest
build-args: |
PROFILE=prod
DB_URL_PROD=${{ secrets.DB_URL_PROD }}
DB_USERNAME_PROD=${{ secrets.DB_USERNAME_PROD }}
DB_PASSWORD_PROD=${{ secrets.DB_PASSWORD_PROD }}
OPEN_API_SERVICE_KEY=${{ secrets.OPEN_API_SERVICE_KEY }}
KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }}
APPLE_CLIENT_ID=${{ secrets.APPLE_CLIENT_ID }}
ACCESS_SECRET=${{ secrets.ACCESS_SECRET }}
REFRESH_SECRET=${{ secrets.REFRESH_SECRET }}
REDIS_HOST=${{ secrets.REDIS_HOST }}
- name: Docker Deploy executing remote ssh commands using ssh_key
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_IP }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
key: ${{ secrets.REMOTE_SSH_KEY }}
port: ${{ secrets.REMOTE_SSH_PORT }}
script: |
docker stop blooming-server || true
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/blooming-server
docker rm -f blooming-server || true
docker run -d --name blooming-server -p ${{ secrets.SERVER_PORT }}:8080 ${{ secrets.DOCKERHUB_USERNAME }}/blooming-server
docker image prune -f