Skip to content

AI 환경 설정

AI 환경 설정 #32

Workflow file for this run

name: CD
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- run: |
mkdir -p ./src/main/resources
touch ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ secrets.DOCKER_IMAGE }}
cache-from: type=gha # gha = Github Actions
cache-to: type=gha,mode=max
- name: Pull from docker hub and deploy
uses: appleboy/ssh-action@master
with:
username: ${{ secrets.REMOTE_USERNAME }}
host: ${{ secrets.REMOTE_HOST }}
key: ${{ secrets.REMOTE_KEY }}
script: |
cd /home/***/Backend
sudo docker compose down
sudo docker image rm ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ secrets.DOCKER_IMAGE }} -f
sudo docker compose up -d