feat: OCR 할 때 카테고리도 추정하게 기능 추가 #32
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: Deploy Backend on Server via DockerHub | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
env: | |
HOST: ${{ secrets.HOST }} | |
USERNAME: ${{ secrets.USERNAME }} | |
KEY: ${{ secrets.SSH_KEY }} | |
PORT: ${{ secrets.PORT }} | |
INSTANCE_PATH: ./savemyreceipt-server | |
IMAGE_NAME: shinsion/savemyreceipt-server | |
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: 'adopt' | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew # Gradle 스크립트 파일에 실행 권한을 부여합니다. | |
- name: Create application.yml | |
run: | | |
mkdir -p ./src/main/resources | |
echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml | |
- name: Create Google Credentials JSON | |
run: | | |
echo "${{ secrets.CLOUD_STORAGE_CREDENTIALS }}" | base64 -d > ./src/main/resources/savemyreceipt-cloud-storage.json | |
echo "${{ secrets.VERTEX_AI_CREDENTIALS }}" | base64 -d > ./src/main/resources/savemyreceipt-vertex-ai.json | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Dockerhub login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get current date and commit SHA | |
id: vars | |
run: | | |
echo "DATE=$(date +%Y%m%d)" >> $GITHUB_ENV | |
echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV | |
- name: Docker image build and push | |
run: | | |
docker buildx create --use | |
docker buildx build --platform linux/amd64,linux/arm64 -t ${{ env.IMAGE_NAME }}:${{ env.DATE }}-${{ env.COMMIT_SHA }} --push . | |
- name: Pull Docker image to server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.HOST}} | |
username: ${{ env.USERNAME }} | |
key: ${{ env.KEY }} | |
port: ${{ env.PORT }} | |
script: | | |
cd ${{ env.INSTANCE_PATH }} | |
docker stop savemyreceipt-server || true | |
docker rm savemyreceipt-server || true | |
docker rmi ${{ env.IMAGE_NAME }}:latest || true | |
docker pull ${{ env.IMAGE_NAME }}:${{ env.DATE }}-${{ env.COMMIT_SHA }} | |
docker tag ${{ env.IMAGE_NAME }}:${{ env.DATE }}-${{ env.COMMIT_SHA }} ${{ env.IMAGE_NAME }}:latest | |
docker compose up -d |