Coder Social home page Coder Social logo

wp-build-hooks's Introduction

Build Hooks

Description

This plugin allows you to trigger a build hook on CircleCI and Gatsby Cloud Services.

CircleCI

Requirements

Terminus Secrets Plugin

You should set a secret key named CIRCLE_CI_TOKEN containing your CircleCI token value in the live environemt of your wordpress site.

https://github.com/pantheon-systems/terminus-secrets-plugin

Configure plugin

To configure the build hook on CircleCI we need add some required values.

On the settings page of this plugin, please select CircleCI for the Web Hook type.

Followed by the repository in format <organization or user>/<project> and the CircleCi Job to execute (e.g pfe/gatsby_build_and_deploy).

Save the settings and now we are ready to trigger a build from our wordpress site

In order to verify if the hook is setting up correctly you can check on the build hook page the Current webhook an url similar to this:

https://circleci.com/api/v1.1/project/gh/<organization or user>/<project>/tree/master?circle-token=72************************************fc

wp-build-hooks's People

Contributors

jmolivas avatar jardix22 avatar digitalhydra avatar omero avatar stevector avatar

Stargazers

Rachel Cherry avatar

Watchers

 avatar James Cloos avatar  avatar Rachel Cherry avatar  avatar

wp-build-hooks's Issues

Test form with bad data

When incorrect values are added for job or repo, a PHP error is shown that includes the full CircleCI token.

Add help text

Add help text to the form that shows the format of the data that is supposed to be entered.
For instance my-github-username/my-github-repo-name.

Add a UI option for setting CircleCI token

I think we saw yesterday that reliance on the Terminus Secrets Plugin can slow down someone installing this plugin.

I still think it makes sense to store the token in an unversioned json file, but let's try writing that file through the UI. Maybe name it secrets.wp-build-hooks.json

PHP warning when setting token

Rachel set up this plugin on a Pantheon live environment and got multiple PHP errors because the secrets.json file or the private directory did not exist yet. Both set_secret() and get_secret() presume that the file exists.

Remove CircleCI field

This configuration is no longer needed , remove from form and avoid storing those values as wp-options
image

Namespace or prefixes or singleton

I'm super excited about what this plugin is enabling content creators to do. Reviewed the code and it seems to work well. I'm just going to submit some issues around best practices for when this moves into the clean up tech debt phase.

To make sure common function names don't conflict with other plugins it is recommended to take steps to make yours unique. It use to be best practice was to prefix the plugin name to all functions but now that the WP minimum supported PHP version has been bumped people have been moving to using name spaces.
https://developer.wordpress.org/plugins/plugin-basics/best-practices/#avoid-naming-collisions

Refactor code

Refactor code into separated file to re-use functions between plugin and CLI commands.

allow full url as input format for repo

The last two people we've walked through setting up this plugin have tried copying the full repo URL (https://github.com/user-name/repo-name) rather than the format CircleCI wants (github/user-name/repo-name). I think we should allow either.

This need might also be an opportunity to start adding automated tests. If we have a function that breaks the user input string into the usable subcomponents (git provider, username, repo name) then that is a very unit-test element.

Add ability to override variables sent to CircleCI

Our current pilot project will need the ability to generate non-live Gatsby previews from non-live WordPress instances. Basically, we need the ability to have a WordPress Multidev where WordPress core updates can be applied and then have a Gatsby site built that reads from that WordPress Multidev environment.

I can add more details and thought about how best to do this, but I wanted to make sure now that I got the issue captured in the queue before daily stand up.

data-source-url is getting sent as a hostname rather than a full url

This command is sending a hostname like mu-my-awesome-site.pantheonsite.io rather than a full url like https://mu-my-awesome-site.pantheonsite.io, which is what we have in examples. I think we should be sending the https:// too in the param name.

This difference isn't breaking anything as long as the Gatsby site getting triggered knows if the incoming param will have https:// or not. But it's worth picking one and aligning this plugin with the orb examples.

Security of secret JSON file

Right now this plugin is using a private json file to store the CircleCI API key. That's more secure than putting it in the database or in version control but we're relying on the private files directory being protected to prevent it from being read publicly. I don't think other hosts have that convention. The default behavior when not on Pantheon might need to be to store the API key in the database.

This task isn't critical right now when all sites using the plugin are on Pantheon, but this should block adding the plugin to the WordPress plugin directory.

Update README

Make sure README reflect latests changes

Actual:

This plugin allows you to trigger a build hook on CircleCI and Gatsby Cloud Services.
Suggestion
This plugin allows you to trigger a build hook on any service provider that supports build hooks.

We currently support wp-options
image

Se support full repo URL and V2 of CircleCI API
image

Broken form on initial configuration

I just installed this plugin on a fresh WordPress site and I'm getting this behavior:

broken-form

Looking closer, it seems like this select list is just causing the entire page to refresh:

ScreenFlow

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.