Deploy Home to Netlify #2
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 Home to Netlify | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: [completed] | |
| branches: [main] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| fetch-depth: 0 | |
| - name: Get parent SHA | |
| id: parent | |
| run: | | |
| PARENT_SHA=$(curl -s "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}" \ | |
| | python3 -c 'import sys,json; print(json.load(sys.stdin)["parents"][0]["sha"])') | |
| echo "sha=$PARENT_SHA" >> $GITHUB_OUTPUT | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| base: ${{ steps.parent.outputs.sha }} | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| filters: | | |
| app: | |
| - 'apps/home/**' | |
| shared: | |
| - 'pnpm-lock.yaml' | |
| - 'pnpm-workspace.yaml' | |
| - 'turbo.json' | |
| - 'tsconfig.base.json' | |
| - name: Check if deploy needed | |
| id: changed | |
| run: | | |
| if [[ "${{ steps.filter.outputs.app }}" == "true" || "${{ steps.filter.outputs.shared }}" == "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: 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 --build --prod --site=$NETLIFY_SITE_ID_HOME --cwd apps/home --message "$DEPLOY_MESSAGE" | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID_HOME: ${{ secrets.NETLIFY_SITE_ID_HOME }} | |
| VITE_TMDB_API_TOKEN: ${{ secrets.VITE_TMDB_API_TOKEN }} | |
| NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} | |
| NEXT_PUBLIC_SENTRY_ENVIRONMENT: production | |
| DEPLOY_MESSAGE: "${{ github.event.workflow_run.head_commit.message }} (${{ github.event.workflow_run.head_sha }})" |