Merge pull request #35 from TheSoftwareDevGuild/redeploy-amoy #1
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 Backend to Heroku | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "backend/**" | |
| - ".github/workflows/deploy-backend.yml" | |
| jobs: | |
| deploy-backend: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Detect backend changes | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| token: ${{ github.token }} | |
| filters: | | |
| backend: | |
| - 'backend/Dockerfile' | |
| - 'backend/Cargo.toml' | |
| - 'backend/Cargo.lock' | |
| - 'backend/src/**' | |
| - 'backend/migrations/**' | |
| - 'backend/rustfmt.toml' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| if: steps.changes.outputs.backend == 'true' | |
| - name: Install Heroku CLI | |
| run: | | |
| curl https://cli-assets.heroku.com/install.sh | sh | |
| if: steps.changes.outputs.backend == 'true' | |
| - name: Heroku Container Registry login | |
| env: | |
| HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }} | |
| HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
| run: | | |
| echo "$HEROKU_API_KEY" | docker login -u "$HEROKU_EMAIL" --password-stdin registry.heroku.com | |
| if: steps.changes.outputs.backend == 'true' | |
| - name: Build and push (linux/amd64) | |
| env: | |
| HEROKU_BACKEND_APP: ${{ secrets.HEROKU_BACKEND_APP }} | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| -t registry.heroku.com/${HEROKU_BACKEND_APP}/web \ | |
| -f backend/Dockerfile backend \ | |
| --push | |
| if: steps.changes.outputs.backend == 'true' | |
| - name: Release on Heroku | |
| env: | |
| HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
| HEROKU_BACKEND_APP: ${{ secrets.HEROKU_BACKEND_APP }} | |
| run: | | |
| heroku container:release web -a "${HEROKU_BACKEND_APP}" | |
| if: steps.changes.outputs.backend == 'true' |