Coder Social home page Coder Social logo

aderaaij / wp-vercel-deploy-hooks Goto Github PK

View Code? Open in Web Editor NEW
68.0 2.0 16.0 1.77 MB

WordPress Plugin to trigger Vercel deploy hooks on command / update

License: GNU General Public License v3.0

PHP 100.00%
wordpress vercel nextjs gatsby headless-wordpress headless-cms jamstack

wp-vercel-deploy-hooks's Introduction

WP Vercel Deploy Hooks

A WordPress plugin to deploy a static site to Vercel when you publish a new WordPress post/page, update a WordPress post/page or deploy on command from the WordPress admin menu and admin bar.

Based on the excellent WordPress Plugin WP Netlify Webhook Deploy.

✅ Features

  • 🚗   Deploy your Vercel project when publishing / updating a WordPress post
  • 👉   Manually deploy your Vercel Project with the push of a button
  • ⏲   Schedule deploys on a daily or weekly basis (mileage may vary).

🛠 Installation

You can install WP Vercel Deploy Hooks manually or through Composer

🤙 Manual Install

  1. Download the plugin as a .zip file from the repository
  2. Login to your WordPress site and go to Plugins -> Add new -> Upload plugin
  3. Locate the .zip file on your machine, upload and activate

🎼 Composer

Composer allows you to install pacakges from a GitHub repository. This repository includes a composer.json file which declares the package as a WordPress plugin. Include it in your project's composer.json as following:

...
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/aderaaij/wp-vercel-deploy-hooks.git"
    }
  ],
  "require": {
    "aderaaij/wp-vercel-deploy-hooks": "main"
  }
...

Now the package will be included in the plugins folder when you use composer install/update.

⚙️ Settings / Configuration

To enable the plugin, you will need to create a Deploy Hook for your Vercel Project.

🎚 Settings

After you've created your deploy hook, navigate to Deploy -> Settings in the WordPress admin menu and paste your Vercel Deploy hook URL. On the settings page you can also activate deploys when you publish or update a post (disabled by default).

You can configure the Vercel Deploy Hook URL in your wp-config.php or other configuration file to be based on your environment using the constant WP_VERCEL_WEBHOOK_ADDRESS. An example follows:

switch (WP_ENVIRONMENT_TYPE) {
    case "live":
    case "production":
        define( 'WP_VERCEL_WEBHOOK_ADDRESS', 'https://api.vercel.com/v1/integrations/deploy/<sample>/<sample>' );
        break;

    case "test":
    case "staging":
        define( 'WP_VERCEL_WEBHOOK_ADDRESS', 'https://api.vercel.com/v1/integrations/deploy/<sample>/<sample>' );
        break;

    case "dev":
    case "development":
        define( 'WP_VERCEL_WEBHOOK_ADDRESS', 'https://api.vercel.com/v1/integrations/deploy/<sample>/<sample>' );
        break;
        
    case "local":
        define( 'WP_VERCEL_WEBHOOK_ADDRESS', 'https://api.vercel.com/v1/integrations/deploy/<sample>/<sample>' );
        break;
}

See https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-function-in-wordpress-5-5/ for more guidance on using WP_ENVIRONMENT_TYPE

⏲ Scheduling

When you enable scheduling it calls the cron_schedules hook which depends on your site having visitors to be triggered. To make sure your schedule is triggered timely, you could schedule a CRON job in your hosting panel which calls wp-cron.php. Please check out the Webhook Netlify Deploy scheduling documentation for more information.

👯 Contributors & Credits

This plugin was based on the excellent WordPress Plugin WP Netlify Webhook Deploy

Made with contrib.rocks.

🤔 To Do

  • Add support for deploy and build statusses and updates through the Vercel API
  • Add support for Netlify Builds and Deploys
  • Add support for multiple Vercel deploy endpoints

wp-vercel-deploy-hooks's People

Contributors

aderaaij avatar barrythrill avatar elliottpost avatar lukethacoder avatar marijoo avatar morlin1129 avatar riddla avatar robmarshall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wp-vercel-deploy-hooks's Issues

Activate deploy on post update doesn't work

I don't know if there is still support for this plugin, but thanks for doing it.
After updating Wordpress to version 6.4.2, when publishing, editing or deleting a post the hook is not called automatically. If you click on the deploy button it works. Can I get any help with this?

Trigger Vercel build when the post is being moved to trash

Hi,

I noticed no build is being triggered when the post is being moved to trash. It seems to be reasonable to trigger a build in such situation, at least when an already published post is being removed, doesn't it?

Otherwise I think it's a nice plugin, I'm trying to build a Next.js application with WordPress backend ;)

Trigger Vercel build when scheduled post gets published

Thanks for developing this plugin, it's very useful!

Does the current set-up allow the Vercel build to be triggered when a scheduled post goes live? I'd like to be able to schedule posts in advance, each with different go live times and then have the build get kicked off for each of them.

Nothing happens after deploy

Hello!

As a noob with both wordpress and Vercel. It could very well be that I have done anything wrong. Before I start I would like to explain what I did:

  1. Created wordpress through XAMPP and I was able to install everything that were needed.
  2. I downloaded a template for Wordpress which I edited. When I click on "Show your website" it will show me the webpage I have edited.
  3. I went to "addition" and added your deploy hooks through wordpress search.
  4. in Vercel. I created a new github with empty folder (Just a readme file) which there after I was able to create hooks through Vercel. etc:

https://api.vercel.com/v1/integrations/deploy/QmX1255eafaef18294712gZYd8 its a fake one :P

  1. I navigated to "Deploy" -> "Setting and added the hook with "Activate deploy on post update"
  2. I went back to Deploy -> Deploy and clicked on Build site and waited 15 min.

And no changes happend either on Vercel or Github.

Is there anything I am missing here? :) My guess is that the WP needs to automatic update to Github where Vercel reads from it?

Edit:

I do see that the POST gets triggered when clicking on the Build site however it seems that it tries to read from the Github folder which is empty. I assume im missing something in between here?

Auto determine hook based on WP Environment

Given the use case of having a different Vercel deploy hook for various environments and git branches, say one for main, one for test, and another for development, it's not currently possible with the plugin to configure these based on environment.

Using a WP host like Pantheon, Acquia, or WPEngine where multiple environments are built in and pair directly with preview environments/branches in Vercel/git, this represents a challenge because every time a site is pushed from one environment to another the Vercel URL is overwritten.

I have created a PR that I'll attach here in a moment that solves this by allowing a user to set these values in wp-config.php or anywhere else that runs before this plugin.

Let editor user build

Hi!
Thank you for this great plugin.
I'd like to let the Editor user build the website after an editing session, without triggering a build on each save.
Having the "build" button for the Editor user would be great.

Is it something you could do or have on your roadmap?

Thank you,
Matteo

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.