Skip to content

Commit

Permalink
feat(cicd): add github workflow for automatic deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ananyo141 committed Mar 10, 2024
1 parent 2b2eba1 commit 15414a5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build And Deploy
on:
push:
branches: [master]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
# scp -rvo "StrictHostKeyChecking=no" $GITHUB_WORKSPACE ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/repo-name
rsync -avzhP -e "ssh -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/video-sharing-platform
- name: Deploy Backend
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.PASSWORD }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /video-sharing-platform
# Run Docker Compose
docker compose -f prod.compose.yml up -d --build

0 comments on commit 15414a5

Please sign in to comment.