Deploy Web to Netlify #58
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 Web to Netlify | |
| on: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: [CI] | |
| types: [completed] | |
| branches: [main] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha || github.sha }} | |
| fetch-depth: 0 | |
| # Path filter — skip deploy if no relevant changes (unless manual trigger) | |
| - name: Get parent SHA | |
| if: github.event_name != 'workflow_dispatch' | |
| id: parent | |
| run: | | |
| PARENT_SHA=$(curl -s "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}" \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| | python3 -c 'import sys,json; print(json.load(sys.stdin)["parents"][0]["sha"])') | |
| echo "sha=$PARENT_SHA" >> $GITHUB_OUTPUT | |
| - uses: dorny/paths-filter@v3 | |
| if: github.event_name != 'workflow_dispatch' | |
| id: filter | |
| with: | |
| base: ${{ steps.parent.outputs.sha }} | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| filters: | | |
| web: | |
| - 'apps/web/**' | |
| packages: | |
| - 'packages/**' | |
| - name: Check if deploy needed | |
| id: changed | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "result=true" >> $GITHUB_OUTPUT | |
| elif [[ "${{ steps.filter.outputs.web }}" == "true" || "${{ steps.filter.outputs.packages }}" == "true" ]]; then | |
| echo "result=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "result=false" >> $GITHUB_OUTPUT | |
| fi | |
| - uses: ./.github/actions/setup | |
| if: steps.changed.outputs.result == 'true' | |
| - name: Build Web | |
| if: steps.changed.outputs.result == 'true' | |
| run: pnpm --filter web-financial-app build | |
| env: | |
| VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }} | |
| VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }} | |
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
| VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }} | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| - name: Install Netlify CLI | |
| if: steps.changed.outputs.result == 'true' | |
| run: pnpm install -g netlify-cli | |
| - name: Deploy to Netlify (Production) | |
| if: steps.changed.outputs.result == 'true' | |
| run: netlify deploy --prod --no-build --site=$NETLIFY_SITE_ID_WEB --cwd apps/web --message "$DEPLOY_MESSAGE" | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID_WEB: ${{ secrets.NETLIFY_SITE_ID_WEB }} | |
| DEPLOY_MESSAGE: "Web deploy — ${{ github.event.workflow_run.head_sha || github.sha }}" |