Skip to content

Workflow file for this run

name: Release Backend on Production Environment
on:
workflow_dispatch:
release:
types:
- published
permissions:
contents: read
env:
IMAGE_NAME: registry.uspray.kr/uspray-server-prod:latest
PROJECT_NAME: uspray-server-prod
DOMAIN_HOST: api.uspray.kr
jobs:
test:
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
- name: Create application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
echo "${{ secrets.APPLICATION_PRODUCTION }}" base64 -d > 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
deliver:
needs: test
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