[BE-INFRA] 개발 서버 배포 #4
Workflow file for this run
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
name: Backend CD | |
on: | |
pull_request: | |
branches: [ "be/develop" ] | |
push: | |
branches: [ "be/develop" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
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: Build with Gradle | |
run: ./gradlew bootJar | |
working-directory: ./backend/pokerogue | |
- name: Docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build --platform=linux/arm64 -t ${{ secrets.DOCKER_SERVER_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile ./backend/pokerogue | |
docker push ${{ secrets.DOCKER_SERVER_IMAGE }} | |
docker build --platform=linux/arm64 -t ${{ secrets.DOCKER_NGINX_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile-nginx ./backend/pokerogue/docker | |
docker push ${{ secrets.DOCKER_NGINX_IMAGE }} | |
deploy: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Change permission | |
run: | | |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-pokerogue-helper | |
- 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 | |
if [ "$(docker ps -qa)" ]; then | |
sudo docker rm -f $(docker ps -qa) | |
else | |
echo "No containers to remove." | |
fi | |
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 |