Skip to content

FIX: Enable Netlify preview deployments for Dependabot PRs#804

Merged
mmcky merged 5 commits intomainfrom
fix/allow-dependabot-netlify-preview
Feb 10, 2026
Merged

FIX: Enable Netlify preview deployments for Dependabot PRs#804
mmcky merged 5 commits intomainfrom
fix/allow-dependabot-netlify-preview

Conversation

@mmcky
Copy link
Contributor

@mmcky mmcky commented Feb 10, 2026

Summary

This PR migrates Netlify preview deployment from custom implementation to the shared quantecon/actions/preview-netlify@v0.6.0 action maintained in the quantecon/actions repository.

Motivation

  1. Enable Dependabot previews: The original motivation was to enable Netlify preview deployments for Dependabot PRs (like ⬆️ Bump quantecon-book-theme from 0.15.1 to 0.16.0 #800) to inspect visual/theme changes before merging.

  2. Reduce code duplication: The custom implementation duplicated ~260 lines of deployment logic that's now centralized across all QuantEcon lecture repositories.

  3. Improve maintainability: The shared action is tested and maintained in one place, making updates and bug fixes easier.

Changes

Replaced ~260 lines of custom code with shared action:

- name: Preview Deploy to Netlify
  uses: quantecon/actions/preview-netlify@v0.6.0
  with:
    netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
    netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
    build-dir: _build/html

Features Preserved

The shared action provides identical functionality:

  • ✅ Automatic Netlify deployment with predictable PR URLs
  • ✅ Changed lecture file detection
  • ✅ Smart PR comments with direct links to modified pages
  • ✅ Duplicate comment prevention
  • ✅ Built-in security handling (automatically skips forks/Dependabot when secrets unavailable)

Setup Required

Dependabot secrets are configured at the organization level to enable previews for Dependabot PRs:

Organization secrets configured at https://github.com/organizations/QuantEcon/settings/secrets/dependabot:

  • NETLIFY_AUTH_TOKEN (Dependabot-specific token)
  • NETLIFY_SITE_ID (same as Actions secrets)

With these configured, Dependabot PRs will automatically get Netlify preview deployments.

Security

The shared action handles security properly:

  • Same repository PRs (including Dependabot with secrets) → Deploy with preview
  • Fork PRs → Skip deployment (can't access secrets)

Benefits

  1. Enables Dependabot previews - The original goal is achieved ✅
  2. Version stability - Using v0.6.0 tag that Dependabot can auto-update
  3. Maintainability - Centralized updates across all QuantEcon lecture repos
  4. Code reduction - 98% less code (-257 lines) in this repository

- Remove github.actor != 'dependabot[bot]' restriction from Netlify deploy step
- Allow visual inspection of dependency updates (e.g., theme changes) before merging
- Update skip message to clarify only fork PRs are blocked for security
- Dependabot PRs are safe as they come from within the same repository
@mmcky mmcky changed the title Enable Netlify preview deployments for Dependabot PRs FIX: Enable Netlify preview deployments for Dependabot PRs Feb 10, 2026
@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-804--sunny-cactus-210e3e.netlify.app (935df28)

…eview-netlify@v0.6.0

- Removes ~260 lines of custom Netlify deployment code
- Uses shared action that provides same functionality:
  - Automatic changed lecture file detection
  - Smart PR comments with direct links
  - Duplicate comment prevention
  - Built-in security handling (skips forks/Dependabot)
- Improves maintainability across QuantEcon repos
- Enables Dependabot to auto-update the action version
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the repository’s Netlify preview deployment logic in CI from an inlined custom implementation to the shared quantecon/actions/preview-netlify@v0.6.0 action, with the stated goal of enabling preview deployments for Dependabot PRs and reducing workflow maintenance burden.

Changes:

  • Replaced the custom Netlify deploy + changed-file detection + PR commenting logic with quantecon/actions/preview-netlify@v0.6.0.
  • Removed explicit Netlify secrets from job-level env and now passes them as action inputs.

- Add contents:read and pull-requests:write permissions
- Required for preview-netlify action to post PR comments
- Addresses Copilot code review feedback
@mmcky
Copy link
Contributor Author

mmcky commented Feb 10, 2026

Copilot Feedback Addressed

Thanks for the review! I've addressed both issues:

✅ Issue 1: Workflow Permissions

Added explicit permissions to the workflow in commit d57db31:

permissions:
  contents: read
  pull-requests: write

This ensures the preview-netlify action can post PR comments even in repositories with restricted default GITHUB_TOKEN permissions.

✅ Issue 2: Dependabot Secrets

The Dependabot secrets concern is already resolved. We've configured organization-level Dependabot secrets:

  • NETLIFY_AUTH_TOKEN (Dependabot-specific token)
  • NETLIFY_SITE_ID

These are available at: https://github.com/organizations/QuantEcon/settings/secrets/dependabot

With this configuration, Dependabot PRs using the pull_request trigger do have access to secrets and will successfully deploy Netlify previews.


The PR is now ready with both Copilot recommendations implemented! 🎉

@mmcky
Copy link
Contributor Author

mmcky commented Feb 10, 2026

@jstac I am starting to see some joy in +7/-263 merges. Hooray for code reduction :-)

- preview-netlify action requires npm to install netlify-cli
- RunsOn custom AMI doesn't have Node.js pre-installed
- Add actions/setup-node@v4 before preview deploy step
@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-804--sunny-cactus-210e3e.netlify.app

Commit: ab970d1


Build Info

@mmcky mmcky merged commit 71764d3 into main Feb 10, 2026
1 check passed
@mmcky mmcky deleted the fix/allow-dependabot-netlify-preview branch February 10, 2026 09:29
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.

1 participant