-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (57 loc) · 1.85 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
56
57
58
59
60
61
62
name: CI/CD Deployment
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the current repository
- name: Checkout backend repo
uses: actions/checkout@v2
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
# Build the Docker image
- name: Build Docker Image
run: |
echo "Building Docker image..."
docker build -t ${{ secrets.DOCKER_USERNAME }}/talker:latest .
echo "Docker image built successfully."
# Push the Docker image to Docker Hub
- name: Push Docker Image
run: |
echo "Pushing Docker image to Docker Hub..."
docker push ${{ secrets.DOCKER_USERNAME }}/talker:latest
echo "Docker image pushed successfully."
# Copy files to VPS
- name: Copy files to VPS
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: ./nginx/default.conf, ./docker-compose.yml
target: /home/${{ secrets.USERNAME }}/app
debug: true
# Deploy to VPS
- name: Deploy to VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
debug: true
script: |
set -e
echo "Starting deployment to VPS..."
cd /home/${{ secrets.USERNAME }}/app
docker compose down
docker compose pull
docker compose up --build
echo "Deployment completed successfully."
'