Skip to content

배포 1.1.0

배포 1.1.0 #54

Workflow file for this run

name: crews backend deploy
on:
push:
branches: [ "main" ]
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: Set up MySQL
uses: mirromutth/[email protected]
with:
mysql database: 'crews'
mysql user: ${{ secrets.TEST_DB_USERNAME }}
mysql password: ${{ secrets.TEST_DB_PASSWORD }}
- name: Run Test And Create API Documentation
run: ./gradlew openapi3
- name: Build with Gradle
run: ./gradlew bootJar -x test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image And Push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_PROD_SERVER_IMAGE_NAME }}
platforms: |
linux/amd64
linux/arm64
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
cd /home/ubuntu
sudo chmod 666 /var/run/docker.sock
docker rm -f $(docker ps -qa)
docker pull ${{ secrets.DOCKER_PROD_SERVER_IMAGE_NAME }}
docker run -d -p 8080:8080 --name crews-server \
-e JAVA_OPTS="-XX:InitialRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0" \
-e SPRING_PROFILES_ACTIVE=prod \
${{ secrets.DOCKER_PROD_SERVER_IMAGE_NAME }}
docker image prune -f
docker volume prune -f