Skip to content

chore: artifact 에서 scp로 변경 #58

chore: artifact 에서 scp로 변경

chore: artifact 에서 scp로 변경 #58

Workflow file for this run

name: crews backend deploy
on:
push:
branches: [ "refactor/#101-apply-reusable-workflow" ]
permissions:
contents: read
jobs:
test:
uses: ./.github/workflows/ci.yml
secrets: inherit
build:
needs: test
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: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Build with Gradle
run: ./gradlew build -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
- name: Copy docker-compose.yml to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
source: "./src/main/resources/config/docker-compose.yml"
target: "/home/ubuntu/docker-compose.yml"
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
sudo chmod +x /usr/local/bin/docker-compose
docker pull ${{ secrets.DOCKER_PROD_SERVER_IMAGE_NAME }}
docker rm -f crews-server
docker-compose up crews-server -d
docker image prune -f
docker volume prune -f