forked from Shurtu-gal/server-api
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (40 loc) · 1.29 KB
/
deploy-digitalocean.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
name: Deploy to DigitalOcean Droplets
on:
push:
branches:
- master
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'master'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to DigitalOcean Droplets
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /home/${{ secrets.USERNAME }}
if [ ! -d "deploy" ]; then
git clone https://github.com/asyncapi/server-api.git deploy
fi
cd deploy
git checkout master
git pull origin master
# Remove old docker containers
docker rm -f $(docker ps -a -q)
# Remove old docker images
docker rmi -f $(docker images -a -q)
# Remove old docker volumes
docker volume rm $(docker volume ls -q)
# Build new docker images
docker build -t asyncapi/server-api .
# Run new docker image
docker run -d -p 80:80 -p 443:443 --restart always --name asyncapi-server-api asyncapi/server-api