Skip to content

develop Deploy

develop Deploy #15

name: develop Deploy
on:
workflow_dispatch:
inputs:
commit_hash:
description: 'commit_hash'
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: DEV
steps:
- name: Deploy to NCP Server
uses: appleboy/ssh-action@master
env:
NCP_CONTAINER_REGISTRY: ${{ secrets.NCP_CONTAINER_REGISTRY }}
NCP_IMAGE_TAG: ${{ github.event.inputs.commit_hash }}
with:
host: ${{ secrets.NCP_HOST }}
username: tenminute
key: ${{ secrets.NCP_PRIVATE_KEY }}
port: ${{ secrets.NCP_PORT }}
envs: NCP_CONTAINER_REGISTRY,NCP_IMAGE_TAG # docker-compose.yml 에서 사용할 환경 변수
script: |
echo "${{ secrets.NCP_SECRET_KEY }}" | docker login -u "${{ secrets.NCP_ACCESS_KEY }}" --password-stdin "${{ secrets.NCP_CONTAINER_REGISTRY }}"
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ github.event.inputs.commit_hash }}
SWAGGER_VERSION=${{ env.NCP_IMAGE_TAG }}
sed -i "s/SWAGGER_VERSION=.*/SWAGGER_VERSION=$SWAGGER_VERSION/" .env
docker compose -f /home/tenminute/docker-compose.yaml up -d
docker image prune -a -f