Code Monkey home page Code Monkey logo

deploy-netlifypress's Introduction

Deploy with NetlifyPress

Deploy with NetlifyPress

Description

Instead of going into Netlify and triggering a deploy everytime you make a change in WordPress, automate and make things easier with the Deploy with NetlifyPress plugin. Deploy with NetlifyPress lets you trigger deploys in Netlify (automatically!) without having to leave your WordPress Dashboard.

Use Cases

So, you've build a headless static front-end for your WordPress site and hosted it on Netlify, good job! Wondering how would you trigger a deploy in Netlify everytime someone updates a post in WordPress? Forget going inside everytime an update is made and triggering a build manually, install Deploy with NetlifyPress and let it run a deploy for you automatically on each update.

If you're looking for a real-life example, I've build my personal site nahid.dev (GitHub) using GatsbyJS with its source as WordPress and am hosting it on Netlify. I use Deploy with NetlifyPress to automate deploys when I update pages and posts.

Core Features

The core features of the plugin include the abilities to:

  • Automatically trigger deploys on post publish
  • Automatically trigger deploys on post update
  • Automatically trigger deploys on post trash
  • Filter the post types for which you want automatic deploys to run
  • Add a button for manual deployments on the top admin toolbar.

Requirements

This plugin requires you have a site hosted on Netlify and a Build Webhook URL set up. Here's how you can get a Build Hook URL:

  1. Log into Netlify.
  2. From the list of sites, enter the site you want to set up Deploy with NetlifyPress for.
  3. Go to Site settings.
  4. From the left sidebar, go to Build and deploy→Continuous Deployment.
  5. Scroll down to the "Build hooks" section.
  6. Click the Add build hook button, enter a preferred name for the webhook (e.g. "Deploy from WordPress"), choose the Git branch to build and hit Save.
  7. You'll be given a Build Hook URL that can be used in Deploy with NetlifyPress.

Install

Automatic Installation

  1. Go to your WordPress Dashboard→Plugins→Add New.
  2. Search for "Deploy with NetlifyPress".
  3. Click on "Install".
  4. Once installed, click on "Activate".

Manual Installation

  1. Download the plugin .zip folder using the download button on this page.
  2. Go to your WordPress Dashboard→Plugins→Add New.
  3. Click on the "Upload Plugin" button.
  4. Upload the downloaded .zip file.
  5. Activate it.

Usage

  1. Install and activate the plugin
  2. Go to your WordPress Dashboard→NetlifyPress
  3. On the "Connect with Netlify" tab, enter your Netlify Build Hook URL.
  4. On the "Automatic Deployment" tab, choose if you want to use Automatic Deployment, on which actions should it trigger and which post types the actions should apply to.
  5. On the "Manual Deployment" tab, choose if you want to add a "Trigger Netlify Deploy" manual trigger button in the top admin toolbar.

Support

If the above usage steps don't answer your question(s), if you want to report an issue or if something is not working as expected, please create a topic in the Support Forum.

Roadmap

I have plans for the following features/improvements in the coming days (subject to user feedback and usage):

  1. Admin options migration to Settings API with Ajax support.
  2. Success/failure message on auto deploy trigger.
  3. Success/failure message on auto deploy status (after completion).
  4. Scheduled deployments.
  5. Deployment logs.

Contribute

If you want to contribute to the plugin by reporting issues, implementing new features and so on, here's its development repository on Github.

Sponsor

You can sponsor this project and support my open-source development by becoming a Patron!

Frequently Asked Questions

Is this plugin free? Definitely! Deploy with NetlifyPress is free and always will be.

How many deploys can I trigger? Unlimited.

deploy-netlifypress's People

Contributors

nfmohit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

jamacon36

deploy-netlifypress's Issues

Automatic Deployment When Working from WordPress iOS

Hello @nfmohit-wpmudev! Big fan of this plugin, it works wonderfully.

I currently use a couple of WordPress deployments that are mostly updated by authors using the WordPress iOS app. In my testing, it seems like publishing or updating a post from the mobile app does not currently take any advantage of this plugin.

I'm curious — I thought there were global sort-of WordPress "hooks" that can be listened to. If these global hooks exist, is this how this plugin works? Is using a "post-published" hook on the WordPress install, triggered by a publish from the app, anywhere in the realm of possibility?

Syntax improvement - main.js

I think that those syntax improvement can be add.

main.js :
(begin of the script)

( function( $ ) { $( document ).ready( function() {

to

( $ => { $(function() {

Because here you have one param (therefore you dont need () ) and you don't use "this" in the first fonction thus you can use a arrow func.

Then next you have the shortcut of ready, like you can see in this documentation : https://learn.jquery.com/using-jquery-core/document-ready/

Changing status to draft

Hi @nfmohit

While working on a similar plugin, but for Buddy.works integration I was trying to tackle the problem related to auto-deployment and while looking at your code I saw one bug.

if ( 'auto-draft' == get_post_status( $post_id ) || 'draft' == get_post_status( $post_id ) || wp_is_post_revision( $post_id ) ) {
    return;
}

So if we will unpublish the post/page it won't run and I think it should as unpublishing changes the content of the page.

I used a bit different approach. First of all I used transition_post_status action and then I went for something like this:

function check_post_status( $new_status, $old_status, $post ) {
  if ( 'auto-draft' === $post->post_status || wp_is_post_revision( $post->ID ) ) {
	  return false;
  }
  
  // publishing or updating something
  if ( 'publish' === $new_status ) {
	  return true;
  }
  
  // unpublishing
  if ( 'publish' !== $new_status && 'publish' === $old_status ) {
	  return true;
  }
  
  return false;
  
}

Of course your functionality is a bit different, but I hope you get the point.

Syntax improvement - php files

I can see in some files that you used :

<?php echo "something" ?>

but you can use in this case directly :

<?= "something" ?>

its a shortcut.

🚀 Feature request : improve build status inside WP dashboard

Hey !

I'm currently using NetlifyPress on all my WordPress Headless and I quickly realized a problem with the editors of WordPress.

Since they are only editors, and therefore do not have access to the Netlify space, they do not know the build status of Netlify.

The idea here would be to have a metabox or some space within the Dashboard with the Netlify status badge.

This would allow to have an overview for the editors and thus avoid having a feedback or having a "spam" on the trigger button.

Another suggestion at the manual build level would be to have a metabox like "There are x unpublished changes", indicating to the user that he has not used the trigger for a while.

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.