This document explains how to set up deploy hooks to ensure Netlify builds AFTER GitHub Actions syncs images to production.
When merging staging → main for production deployment:
Use Netlify Deploy Hooks to trigger production builds AFTER GitHub Actions completes the image sync.
Run the setup script (requires Netlify login):
npm run setup:deploy-hooksThis will create a build hook in Netlify and output a URL like:
https://hooks.netlify.com/abc123xyz...
NETLIFY_DEPLOY_HOOK_PRODUCTIONWhen you merge staging → main:
.github/workflows/sync-images-to-production.yml:
jobs:
sync-images:
steps:
# 1. Sync images from preview to production
- name: Sync images from Preview to Production
run: node scripts/sync-preview-to-production.js
# 2. Trigger Netlify build (only if sync succeeded)
- name: Trigger Netlify Production Build
if: success()
run: |
curl -X POST -H "Content-Type: application/json" \
-d '{}' "$"netlify.toml:
[context.production]
# Production builds are triggered by GitHub Actions
# No upload needed - images already synced
command = "npm run build-ci"To test the setup without deploying to production:
staging branch (normal behavior)staging → mainCheck that the secret is set correctly:
# List secrets (requires GitHub CLI)
gh secret listVerify the hook exists in Netlify:
npx netlify hooks:listCheck the GitHub Actions logs:
https://github.com/cadextcp/RetroComputerDD/actions/workflows/sync-images-to-production.yml
.github/workflows/sync-images-to-production.yml - GitHub Actions workflownetlify.toml - Netlify configurationscripts/sync-preview-to-production.js - Image sync scriptscripts/setup-netlify-deploy-hooks.js - Hook setup script