Skip to content

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

[BE-INFRA] 개발 서버 배포

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

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: self-hosted
steps:
- name: Change permission
run: |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-pokerogue-helper
- 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
docker push ${{ secrets.DOCKER_NGINX_IMAGE }}
- name: Deploy
run: |
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