Skip to content

Commit

Permalink
Create deploy.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
b4hia authored Dec 2, 2024
1 parent 6db726e commit c13c049
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy

on:
push:
branches:
- main

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

- name: Set permissions for private key
run: |
echo "${{ secrets.KEYAWS }}" > key.pem
chmod 600 key.pem
- name: Stop running containers
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@98.80.44.121 'if [ -d /home/ubuntu/tupan-back/ ]; then cd /home/ubuntu/tupan-back/ && sudo docker-compose down; fi'
- name: Deploy to EC2
run: |
rsync -av --delete ./ ubuntu@98.80.44.121:/home/ubuntu/tupan-back
- name: Run Docker Compose
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@98.80.44.121 'cd /home/ubuntu/tupan-back && sudo docker-compose up -d'
- name: Cleanup
run: |
rm -f key.pem

0 comments on commit c13c049

Please sign in to comment.