-
Notifications
You must be signed in to change notification settings - Fork 2
52 lines (46 loc) · 1.68 KB
/
docker-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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