Skip to content

Commit 2cfa380

Browse files
authored
Create main.yml
1 parent fbc527f commit 2cfa380

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deployment CAPEC-Rag
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy-to-vm:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up SSH
17+
uses: webfactory/[email protected]
18+
with:
19+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
20+
21+
- name: Add Azure VM to known_hosts
22+
run: |
23+
mkdir -p ~/.ssh
24+
ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts
25+
26+
- name: Synchronize Code with VM Using rsync
27+
env:
28+
RSYNC_RSH: "ssh"
29+
run: |
30+
rsync -avz --checksum --exclude='.git' ./ ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/home/dev/
31+
32+
- name: Restart Docker Compose Services
33+
uses: appleboy/[email protected]
34+
with:
35+
host: ${{ secrets.VM_HOST }}
36+
username: ${{ secrets.VM_USER }}
37+
key: ${{ secrets.SSH_PRIVATE_KEY }}
38+
script: |
39+
echo "Stopping existing Docker Compose services..."
40+
cd /home/dev/
41+
sudo docker-compose down
42+
echo "Starting Docker Compose services..."
43+
sudo docker-compose build --no-cache
44+
sudo docker-compose up -d
45+
echo "Successfully deployed the application!"

0 commit comments

Comments
 (0)