Skip to content

Add GitHub Deployments sync for Netlify previews#4459

Merged
hardillb merged 1 commit intomainfrom
feature/github-deployments-sync
Jan 26, 2026
Merged

Add GitHub Deployments sync for Netlify previews#4459
hardillb merged 1 commit intomainfrom
feature/github-deployments-sync

Conversation

@dimitrieh
Copy link
Contributor

@dimitrieh dimitrieh commented Jan 26, 2026

Description

This PR adds a GitHub Actions workflow that syncs Netlify preview deployments to GitHub's native Deployments API.

The Problem

Netlify does not natively create GitHub Deployment objects when deploying preview builds. While Netlify successfully posts PR comments and status checks, it does not use GitHub's Deployments API. This has been a long-standing limitation that Netlify has consistently declined to implement despite user requests since 2020.

As a result, GitHub's deployment UI shows "This branch has not been deployed" with "No deployments" on pull requests.

CleanShot 2026-01-26 at 14 04 50@2x

How This Works

The workflow is event-driven and automatic:

  1. Netlify deploys a preview → posts commit status to GitHub
  2. GitHub fires a status event → triggers this workflow
  3. Workflow creates a GitHub Deployment object → links to Netlify preview URL
  4. GitHub UI updates → shows "Preview" environment with deployment link

No polling, no periodic checks, no wasted Actions minutes. The workflow only runs when Netlify posts a successful preview deployment status.

No Conflicts

This workflow is safe and isolated:

  • Per-PR isolation: Each PR gets its own deployment object based on unique commit SHAs
  • Multiple PRs: Work independently without interference
  • Multiple commits: Old deployments are automatically marked inactive
  • Existing workflows: Uses separate status event trigger, doesn't affect other workflows
  • Production deployments: Only affects preview deployments (filtered by Netlify context)

Minimal Permissions

The workflow has restricted permissions:

  • deployments: write - Only creates deployment metadata
  • statuses: read - Only reads Netlify status checks
  • contents: read - Only reads repository info

Cannot modify code, push commits, or access secrets.

Related Issue(s)

Resolves the issue where GitHub's deployment UI shows "No deployments" despite Netlify successfully deploying preview builds.

Checklist

  • I have read the contribution guidelines
  • I have considered the performance impact of these changes
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
  • For blog PRs, an Art Request has been created (instructions)

Netlify does not natively create GitHub Deployment objects when
deploying preview builds. This workflow listens for Netlify status
events and creates corresponding GitHub Deployment objects, making
preview deployments visible in GitHub's native deployment UI.

The workflow triggers on Netlify preview deployment success and
creates a transient Preview environment with a link to the Netlify
preview URL.
@netlify
Copy link

netlify bot commented Jan 26, 2026

Deploy Preview for flowforge-website ready!

Name Link
🔨 Latest commit 9c49629
🔍 Latest deploy log https://app.netlify.com/projects/flowforge-website/deploys/6977666cc60b300007def668
😎 Deploy Preview https://deploy-preview-4459--flowforge-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 81 (🟢 up 24 from production)
Accessibility: 80 (no change from production)
Best Practices: 100 (🟢 up 8 from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@dimitrieh
Copy link
Contributor Author

dimitrieh commented Jan 26, 2026

This PR doesn't yet show a deployment status as GitHub only runs workflows that exist on the main branch, so this workflow won't activate until after it's merged. This is a security measure to prevent malicious code in PRs from executing.

Once merged, all future PRs will automatically get deployment objects when Netlify deploys them. To test it, just create a new PR after merging this one.

@dimitrieh
Copy link
Contributor Author

@hardillb can you give this a review?

Created this as #4431 is an example where the deployment comment from Netlify is not creating a linear story in the PR. I was confused if it actually deployed the latest changes or not. Also, the having the github deployment status it has not been deployed is not really productive 🙃. This PR should resolve that once merged to master

CleanShot 2026-01-26 at 14 30 31@2x

@dimitrieh dimitrieh requested a review from hardillb January 26, 2026 13:31
@hardillb
Copy link
Contributor

@ppawlowski might want to look at this to go with the pre-staging stuff we were talking about in the dev team meeting

@hardillb hardillb merged commit 8ce84c6 into main Jan 26, 2026
7 checks passed
@hardillb hardillb deleted the feature/github-deployments-sync branch January 26, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants