deploy #128
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: Deploy to NCP | |
on: | |
repository_dispatch: | |
types: [deploy] | |
env: | |
IMAGE_NAME: koliving_fe | |
NAVER_S3_ENDPOINT: https://kr.object.ncloudstorage.com | |
BUCKET_NAME: front-storybook | |
jobs: | |
docker-deploy: | |
runs-on: ubuntu-latest | |
if: github.repository == 'bsideproject/KoLiving_FE' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Copy Docker Compose file to NCP Server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.NCP_SERVER_IP }} | |
username: ${{ secrets.NCP_SERVER_USERNAME }} | |
password: ${{ secrets.NCP_SERVER_PASSWORD }} | |
port: ${{ secrets.NCP_SERVER_PORT }} | |
source: docker-compose.yml | |
target: /deploy/scripts | |
- name: Connect ssh to NCP Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.NCP_SERVER_IP }} | |
username: ${{ secrets.NCP_SERVER_USERNAME }} | |
password: ${{ secrets.NCP_SERVER_PASSWORD }} | |
port: ${{ secrets.NCP_SERVER_PORT }} | |
script: | | |
cd /deploy/scripts | |
echo ${{ secrets.NCP_NCR_SECRET_KEY }} | docker login -u ${{ secrets.NCP_NCR_ACCESS_KEY }} --password-stdin ${{ secrets.NCP_NCR }} | |
docker pull ${{ secrets.NCP_NCR }}/${{env.IMAGE_NAME}}:latest | |
export BUILD_NUMBER=latest | |
export NCP_NCR=${{ secrets.NCP_NCR }} | |
export IMAGE_NAME=${{ env.IMAGE_NAME }} | |
if [[ $(docker ps -q) ]]; then | |
docker stop $(docker ps -q) | |
docker rm $(docker ps -aq) | |
else | |
echo "No running containers found." | |
fi | |
docker-compose up -d | |
docker logout |