Skip to content

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
run: |
docker build -t my-backend:latest -f Dockerfile .
- name: Save Docker image to a tar file
run: |
docker save my-backend:latest -o my-backend.tar
- name: Copy Docker image to VM
uses: appleboy/scp-action@v0.1.1
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.VM_SSH_KEY }}
source: "my-backend.tar"
target: "/home/azureuser/docker-images/my-backend.tar"
- name: Load Docker image on VM
run: |
ssh -i ${{ secrets.VM_SSH_KEY }} ${{ secrets.VM_USERNAME }}@${{ secrets.VM_HOST }} 'docker load -i /home/azureuser/docker-images/my-backend.tar'