Jump to content

CI Trigger


thomasaull
 Share

Recommended Posts

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

  • Like 5
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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;

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...