Skip to content

Deploy Media to Netlify #1

Deploy Media to Netlify

Deploy Media to Netlify #1

Workflow file for this run

name: Deploy Media 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/media/**'
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_MEDIA --cwd apps/media --message "$DEPLOY_MESSAGE"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID_MEDIA: ${{ secrets.NETLIFY_SITE_ID_MEDIA }}
VITE_TMDB_API_TOKEN: ${{ secrets.VITE_TMDB_API_TOKEN }}
DEPLOY_MESSAGE: "${{ github.event.workflow_run.head_commit.message }} (${{ github.event.workflow_run.head_sha }})"