Refactor/190 pray (#191) #64
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: Deploy Backend on Development Environment | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- deploy/v2-workflow | |
permissions: | |
contents: read | |
env: | |
IMAGE_NAME: registry.uspray.kr/uspray-server-dev:latest | |
PROJECT_NAME: uspray-server-dev | |
DOMAIN_HOST: api.dev.uspray.kr | |
jobs: | |
deliver: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "11" | |
distribution: "temurin" | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew # Gradle 스크립트 파일에 실행 권한을 부여합니다. | |
- name: Create application.yml | |
run: | | |
mkdir -p ./src/main/resources | |
cd ./src/main/resources | |
echo "${{ secrets.APPLICATION }}" >> ./application.yml | |
- name: Create service-account-file.json | |
run: | | |
mkdir -p ./src/main/resources/firebase | |
cd ./src/main/resources/firebase | |
echo "${{ secrets.SERVICE_ACCOUNT_FILE }}" | base64 -d > service-account-file.json | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_NAME }} | |
platforms: linux/amd64 | |
deploy: | |
needs: deliver | |
runs-on: self-hosted | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Deploy Docker image | |
env: | |
SERVICE_NAME: ${{ env.PROJECT_NAME }} | |
DOMAIN_HOST: ${{ env.DOMAIN_HOST }} | |
IMAGE_NAME: ${{ env.IMAGE_NAME }} | |
run: | | |
if [ ! -z "$(docker ps -q -f name=${{env.PROJECT_NAME}})" ]; then | |
docker compose -p ${{env.PROJECT_NAME}} down | |
docker rmi ${{env.IMAGE_NAME}} | |
fi | |
docker compose -p ${{env.PROJECT_NAME}} up -d |