-
-
Notifications
You must be signed in to change notification settings - Fork 130
55 lines (45 loc) · 1.54 KB
/
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
53
54
55
name: Deploy to DigitalOcean
on:
push:
branches:
- setup/digital-ocean
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker images
run: docker-compose build
- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add DigitalOcean droplet to known_hosts
run: |
ssh-keyscan ${{ secrets.DROPLET_IP }} >> ~/.ssh/known_hosts
- name: Save and transfer API image to DigitalOcean
run: |
set -e
IMAGE_API_ID=$(docker images -q abibliadigital-api:latest)
echo "API Image ID: $IMAGE_API_ID"
if [ -z "$IMAGE_API_ID" ]; then
echo "API image not found!"
exit 1
fi
docker save $IMAGE_API_ID | bzip2 | ssh root@${{ secrets.DROPLET_IP }} 'bunzip2 | docker load'
- name: Save and transfer Mongo image to DigitalOcean
run: |
set -e
IMAGE_MONGO_ID=$(docker images -q abibliadigital-mongo:latest)
echo "Mongo Image ID: $IMAGE_MONGO_ID"
if [ -z "$IMAGE_MONGO_ID" ]; then
echo "Mongo image not found!"
exit 1
fi
docker save $IMAGE_MONGO_ID | bzip2 | ssh root@${{ secrets.DROPLET_IP }} 'bunzip2 | docker load'
- name: Deploy to DigitalOcean
run: |
ssh root@${{ secrets.DROPLET_IP }} "docker-compose -f /path/to/docker-compose.yml up -d"