Skip to content

[BE-INFRA] 개발 서버 배포 #8

[BE-INFRA] 개발 서버 배포

[BE-INFRA] 개발 서버 배포 #8

Workflow file for this run

name: Backend CI
on:
pull_request:
branches: [ "be/develop" ]
push:
branches: [ "be/develop" ]
permissions:
contents: read
jobs:
build:
env:
working-directory: ./backend/pokerogue
docker-directory: ./backend/pokerogue/docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTION_TOKEN }}
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run Test
run: ./gradlew clean test
working-directory: ${{ env.working-directory }}
- name: Build with Gradle
run: ./gradlew bootJar
working-directory: ${{ env.working-directory }}
- name: Docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_SERVER_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile ./backend/pokerogue
docker push ${{ secrets.DOCKER_SERVER_IMAGE }}
docker build -t ${{ secrets.DOCKER_NGINX_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile-nginx ./backend/pokerogue
docker push ${{ secrets.DOCKER_NGINX_IMAGE }}
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
cd /home/ubuntu
sudo touch docker-compose.yml
echo "${{ vars.DOCKER_COMPOSE }}" | sudo tee docker-compose.yml > /dev/null
sudo chmod 666 /var/run/docker.sock
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_SERVER_IMAGE }}
sudo docker pull ${{ secrets.DOCKER_NGINX_IMAGE }}
docker-compose -f docker-compose.yml up -d
docker image prune -f