-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |