Automatic Netlify builds on WordPress publish and update events.
- Makes it super easy to keep a static frontend in sync with your post database
- Out of the box support for configuration with .env
- Full composer support
- Supports custom posttypes
- Supports custom publish hooks
- Free & open source
- WordPress 5.2+
- PHP 7.2+
composer require pixelcollective/netlify-deploy
Request a webhook URL from Netlify to use to trigger builds (you can find the "Build hooks" section on your site dashboard at /settings/deploys#build-hooks
).
Next, add the URL to your site .env variables and activate the plugin. Env variables are included in .env.example
and below, for your reference:
## Hooks
NETLIFY_WEBHOOK_DEVELOPMENT=https://api.netlify.com/build_hooks/{yourBuildHookId}
NETLIFY_WEBHOOK_STAGING=https://api.netlify.com/build_hooks/{yourBuildHookId}
NETLIFY_WEBHOOK_PRODUCTION=https://api.netlify.com/build_hooks/{yourBuildHookId}
By default the plugin makes a run on the provided Netlify webhook when the standard WordPress posttypes post
and page
undergo a change in publish
status.
If you would like to modify this you can do so by passing an array of desired posttypes to the netlify_posttypes
filter.
add_filter('netlify_posttypes', [
'post',
'page',
'video-film',
'brandon-small-jokes',
]);
You can modify your webhooks at runtime using the netlify_hooks
filter:
add_filter('netlify_hooks', [
'development' => 'https://api.netlify.com/build_hooks/########',
'testing' => 'https://api.netlify.com/build_hooks/########',
'production' => 'https://api.netlify.com/build_hooks/########',
])
If you don't want to use env variables because you don't have a deployment strategy and enjoy living poorly you can hook into the netlify_env_override
filter and pass the target webhook directly at runtime:
add_filter('netlify_env_override', 'https://api.netlify.com/build_hooks/########');
Change the post status transitions which trigger a build. Usage with the default values is shown below:
add_filter('netlify_transitions', [
'draft_to_publish',
'publish_to_draft',
'publish_to_trash',
'publish_to_private',
'private_to_public',
'new_to_publish',
]);
👤 Tiny Pixel Collective, LLC
- Twitter: @tinydevteam
- Github: @pixelcollective
- Web: tinypixel.dev
Contributions, issues and feature requests are welcome!
🧠 ? Open a PR. Be sure to abide by our contribution guidelines.
😩 ? Open an issue.
We need ⭐️s to live. Please.
This project is MIT licensed.
Copyright © 2019 Tiny Pixel Collective, LLC.