-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.91 KB
/
dev.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
name: dev
on:
push:
branches: [develop]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Get current time
uses: josStorer/[email protected]
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"
- uses: actions/checkout@v2
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
docker build -f ./docker/Dockerfile-dev -t taewan2002/docent-front:${{steps.current-time.outputs.formattedTime}} .
docker push taewan2002/docent-front:${{steps.current-time.outputs.formattedTime}}
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.NCP_HOST_DEV }}
port: 1024
username: ${{ secrets.NCP_USER_DEV }}
password: ${{ secrets.NCP_PASSWORD_DEV }}
key: ${{ secrets.NCP_KEY }}
envs: GITHUB_SHA
script: |
# Pull the new image
echo "🐳 Docker Image Pull"
sudo docker pull taewan2002/docent-front:${{steps.current-time.outputs.formattedTime}}
# Stop & Start
echo "🐳 Docker Stop & Start"
sudo docker stop docent-front
sudo docker run --rm -d --name docent-front -p 3000:3000 taewan2002/docent-front:${{steps.current-time.outputs.formattedTime}}
# Check
echo "🐳 Docker ps"
docker ps
# Cleanup old images
echo "🧹 Cleaning up old Docker images"
sudo docker rmi -f $(sudo docker images -q) || true