Skip to content

Commit 217904e

Browse files
committed
chore (deployment): added ci cd for development branch
1 parent 0b4cc27 commit 217904e

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

.github/workflows/deploy-dev.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# .github/workflows/deploy-stag.yaml
2+
name: Deploy to development VM
3+
4+
on:
5+
# This section defines when the workflow will run.
6+
push:
7+
branches:
8+
- development # Trigger on every push to the "development" branch.
9+
10+
jobs:
11+
deploy:
12+
# The job will run on a fresh virtual machine provided by GitHub.
13+
runs-on: ubuntu-latest
14+
steps:
15+
# This is the main step that does the work.
16+
- name: Deploy over SSH
17+
# It uses a pre-made Action from the community to simplify SSH.
18+
uses: appleboy/ssh-action@master
19+
with:
20+
# These values are securely pulled from your GitHub Secrets.
21+
host: ${{ secrets.DEV_VM_HOST }}
22+
username: ${{ secrets.DEV_VM_USER }}
23+
key: ${{ secrets.DEV_VM_SSH_PRIVATE_KEY }}
24+
25+
# This is the script that the Action will run on your VM.
26+
script: |
27+
# Change to your project's directory on the VM.
28+
cd ~/sentient
29+
30+
# Pull the latest changes from the development branch on GitHub.
31+
git pull origin development
32+
33+
# Navigate into the server directory where your docker-compose file is.
34+
cd src/server
35+
36+
# Stop and remove the old containers.
37+
docker-compose down
38+
39+
# Build new images if the Dockerfile has changed, and start the new containers in the background.
40+
docker-compose up --build -d
41+
42+
# Optional: This cleans up any old, unused Docker images to save disk space.
43+
docker image prune -af
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# .github/workflows/deploy.yml
1+
# .github/workflows/deploy-stag.yaml
22
name: Deploy to Staging VM
33

44
on:
@@ -18,9 +18,9 @@ jobs:
1818
uses: appleboy/ssh-action@master
1919
with:
2020
# These values are securely pulled from your GitHub Secrets.
21-
host: ${{ secrets.VM_HOST }}
22-
username: ${{ secrets.VM_USER }}
23-
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
21+
host: ${{ secrets.STAG_VM_HOST }}
22+
username: ${{ secrets.STAG_VM_USER }}
23+
key: ${{ secrets.STAG_VM_SSH_PRIVATE_KEY }}
2424

2525
# This is the script that the Action will run on your VM.
2626
script: |

0 commit comments

Comments
 (0)