feat: add robust restort workflow. #90
This file contains hidden or 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
| name: Deploy to staging | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: staging | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Copy project files to production server | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: root | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| source: "." | |
| target: "/root/survey-app" | |
| strip_components: 0 | |
| rm: false | |
| overwrite: true | |
| - name: Upload .env file | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: root | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| cat << 'EOF' > /root/survey-app/.env | |
| ${{ secrets.ENV_FILE }} | |
| EOF | |
| - name: Upload Caddyfile | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: root | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| cat << 'EOF' > /root/survey-app/Caddyfile | |
| ${{ secrets.CADDY_FILE }} | |
| EOF | |
| - name: Upload Firebase Service Account | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: root | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| cat << 'EOF' > /root/survey-app/backend/src/main/resources/firebase-service-account.json | |
| ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} | |
| EOF | |
| - name: Deploy with Docker Compose | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: root | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| cd /root/survey-app | |
| docker compose down | |
| docker compose --env-file .env up -d --build | |