Prompt
Why are my preview deployments failing in GitHub Actions?
Latest observation
Preview deployments in GitHub Actions usually fail for a handful of common reasons. The exact cause depends on your workflow logs, but here are the most likely issues to check first:
1) Missing or incorrect secrets
Your deployment step may rely on secrets such as:
GITHUB_TOKEN- cloud provider credentials
- API keys for your hosting platform
Check:
- the secret names in your workflow match exactly
- the secrets exist in the repo/org settings
- the workflow has permission to read them
2) Insufficient GitHub Actions permissions
If you’re deploying to GitHub Pages, environments, or creating PR comments, the workflow may need explicit permissions, such as:
permissions:
contents: read
pull-requests: write
id-token: write
3) Environment protection rules blocking deployment
If you use GitHub Environments, deployments may be waiting for:
- required reviewers
- branch restrictions
- manual approval
Check the Environment tab in your repo settings.
4) Build failures before deployment
Sometimes the “deployment” fails because the app never built successfully:
- dependency install errors
- test failures
- missing build output
- wrong Node/Python version
- incompatible package lockfile
Look earlier in the logs for the first actual error.
5) Wrong build artifact path
If your deploy step expects a folder like dist/, build/, or .next/, but your build produces something else, deployment will fail.
Example:
- name: Build
run: npm run build
- name: Deploy
uses: some/deploy-action@v1
with:
path: ./dist
Make sure path matches the actual output directory.
6) Preview URL or PR comment step failing
Some preview workflows fail when:
- the action can’t post a PR comment
- the pull request comes from a fork
- the token doesn’t have permission to write comments
- the deployment URL is invalid or missing
7) Branch / event mismatch
Your workflow may only run on:
pushtomainpull_requeston certain branches
If preview deployments are expected on PRs, confirm the workflow is triggered by:
on:
pull_request:
8) Deployment platform errors
If you deploy to Vercel, Netlify, Cloudflare Pages, AWS, etc., the platform itself may be rejecting the deployment because of:
- invalid project ID
- expired token
- wrong team/account
- rate limits
- failed environment configuration
Best next step
Paste the workflow YAML and the exact error message from the Actions log. The first failing step usually points directly to the problem, and I can help you pinpoint it quickly.