-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (34 loc) · 1.1 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
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: Add SSH key
run: |
echo "${{ secrets.VM_SSH_KEY }}" > /tmp/vm_ssh_key
chmod 600 /tmp/vm_ssh_key
- name: Copy Docker image to VM
uses: appleboy/[email protected]
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
key: /tmp/vm_ssh_key
source: "my-backend.tar"
target: "/home/azureuser/docker-images/my-backend.tar"
- name: Load Docker image on VM
run: |
ssh -i /tmp/vm_ssh_key ${{ secrets.VM_USERNAME }}@${{ secrets.VM_HOST }} 'docker load -i /home/azureuser/docker-images/my-backend.tar'