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 Frontend to Heroku | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "frontend/**" | |
| - ".github/workflows/deploy-frontend.yml" | |
| jobs: | |
| deploy-frontend: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Detect frontend changes | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| token: ${{ github.token }} | |
| filters: | | |
| frontend: | |
| - 'frontend/Dockerfile' | |
| - 'frontend/package.json' | |
| - 'frontend/package-lock.json' | |
| - 'frontend/astro.config.mjs' | |
| - 'frontend/src/**' | |
| - 'frontend/public/**' | |
| - 'frontend/vitest.config.ts' | |
| - 'frontend/tsconfig.json' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| if: steps.changes.outputs.frontend == 'true' | |
| - name: Install Heroku CLI | |
| run: | | |
| curl https://cli-assets.heroku.com/install.sh | sh | |
| if: steps.changes.outputs.frontend == '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.frontend == 'true' | |
| - name: Build and push (linux/amd64) | |
| env: | |
| HEROKU_FRONTEND_APP: ${{ secrets.HEROKU_FRONTEND_APP }} | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| -t registry.heroku.com/${HEROKU_FRONTEND_APP}/web \ | |
| -f frontend/Dockerfile frontend \ | |
| --push | |
| if: steps.changes.outputs.frontend == 'true' | |
| - name: Release on Heroku | |
| env: | |
| HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
| HEROKU_FRONTEND_APP: ${{ secrets.HEROKU_FRONTEND_APP }} | |
| run: | | |
| heroku container:release web -a "${HEROKU_FRONTEND_APP}" | |
| if: steps.changes.outputs.frontend == 'true' |