-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (34 loc) · 1.29 KB
/
docker.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
name: Build and Deploy Microservices
on:
push:
branches: ["deploy"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Build all Docker images
run: docker compose build --progress=plain --no-cache
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Save all Docker images
run: |
docker images -q --format="{{.Repository}}:{{.Tag}}" | while read image; do
docker save "$image" > "$image".tar
done
- name: Transfer images to server via SSH
uses: appleboy/ssh-action@master
with:
host: 37.139.41.110
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo mkdir -p /opt/docker-images
docker images -q --format="{{.Repository}}:{{.Tag}}" | while read image; do
cat "$image".tar | sudo docker load -i -
done
sudo docker compose up -d --remove-orphans