thomasaull Posted February 28, 2019 Posted February 28, 2019 I created a little helper module to trigger a CI pipeline when your website has been changed. It's quite simple and works like this: As soon as you save a page the module sets a Boolean via a pages save after hook. Once a day via LazyCron the module checks if the Boolean is set and sends a POST Request to a configurable Webhook URL. Some ideas to extend this: make request type configurable (GET, POST) make the module trigger at a specified time (probably only possible with a server cronjob) trigger manually Anything else? If there's interest, I might put in some more functionality. Let me know what you're interested in. Until then, maybe it is useful for a couple of people ? Github Repo: https://github.com/thomasaull/CiTrigger 5
dragan Posted February 28, 2019 Posted February 28, 2019 This sounds great! Thanks for sharing this module. As I am only recently getting my feet wet with CI/CD, I wonder: Do you "only" trigger a webhook (basically notifiying some other service that something has changed), or do you also send along infos about what and where changes have occured? From your description I assume it's the former. If so, how would the webhook know what exactly has been changed? Or is that part of the whole CI/CD setup / logic entirely up to the pipeline definition / task? Sorry if I'm asking blatantly obvious, stupid questions. I guess your module would most likely be suited for syncing dev and live instances? (site contents) If I change a field or template configuration, would this also trigger a webhook? (I guess not)
gmclelland Posted February 28, 2019 Posted February 28, 2019 Sounds pretty similar to a Drupal based module I just heard about. https://www.drupal.org/project/build_hooks and here is where I read about it https://weknowinc.com/blog/improving-drupal-and-gatsby-integration-drupal-modules Maybe that Drupal module would give you some more ui or functionality ideas? 1
thomasaull Posted March 1, 2019 Author Posted March 1, 2019 15 hours ago, dragan said: This sounds great! Thanks for sharing this module. As I am only recently getting my feet wet with CI/CD, I wonder: Do you "only" trigger a webhook (basically notifiying some other service that something has changed), or do you also send along infos about what and where changes have occured? From your description I assume it's the former. If so, how would the webhook know what exactly has been changed? Or is that part of the whole CI/CD setup / logic entirely up to the pipeline definition / task? Sorry if I'm asking blatantly obvious, stupid questions. I guess your module would most likely be suited for syncing dev and live instances? (site contents) If I change a field or template configuration, would this also trigger a webhook? (I guess not) @dragan Yes, it basically only sends a POST Request to a webhook url without any further information. So your assumption is correct ? In my case the CI Pipeline does a static build of the website and deploys it on the server. What happens in your build pipeline is totally up to you though. You could also do a request from your pipeline to your API to gather further information if needed. The trigger does not become active for system templates and pages which are not public, this is the related code: // do nothing for system pages: if ($page->template->flags === Template::flagSystem) return; // do nothing if page is not public if (!$page->isPublic) return;
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now