Skip to content

Build, Test, and Push Services #12

Build, Test, and Push Services

Build, Test, and Push Services #12

Workflow file for this run

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