Skip to content

Commit

Permalink
Merge pull request #203 from Funssion-SWM/recovery-shell
Browse files Browse the repository at this point in the history
feat(cd): add recovery shell script when reboot
  • Loading branch information
goathoon authored May 18, 2024
2 parents 8eb2185 + ec988de commit 13324dc
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/temp-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,24 @@ jobs:
- name: Docker push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}

- name: Deploy to dev
- name: Deploy to dev & Add recovery shell script when reboot
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD }}
username: ec2-user
key: ${{ secrets.NEW_PRIVATE_KEY }}
script: |
docker stop backend
docker rm backend
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}
docker run -dp 8080:8080 --name=backend ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}
cat << EOF > /var/lib/cloud/scripts/per-boot/recover.sh
#!/bin/bash
docker restart nginx
docker restart frontend
docker restart backend
EOF
chmod +x /var/lib/cloud/scripts/per-boot/recover.sh
docker stop backend
docker rm backend
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}
docker run -dp 8080:8080 --name=backend ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_PROD_REPO }}

0 comments on commit 13324dc

Please sign in to comment.