Jump to content
Jorge

Commit & push to github after page save

Recommended Posts

Hi.

I'm trying  a new combo with Processwire + Gridsome + Netlify.
My data is in Processwire, available via a custom API and I'm fetching it with Axios to the Gridsome data layer. Everytime I push my code to Github, Netlify will deploy a new version of the site with the updated content.

What's missing is some kind of automation that allows me to commit & push to Github every time a page is saved in Processwire.

Does anyone know how to do that or point me in the right direction?

Thanks.

Share this post


Link to post
Share on other sites

@Jorge,

Welcome to the forums 🙂

23 minutes ago, Jorge said:

What's missing is some kind of automation that allows me to commit & push to Github every time a page is saved in Processwire.

There's 2 - 3 issues here:

  1. Every time a page is saved: Easily achieved using ProcessWire Hooks
  2. Commit and Push to Github: How are you currently doing this? Are you pushing from the server where you have installed ProcessWire? This is related to #1, basically, what you will do when you call your Hook
  3. Automation: Depend on your case this and #2 could be one and the same. Or this could be an independent process, e.g. a cron job triggered by #1 which then calls #2

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi @Jorge, welcome to the forums.

As Kongondo already said, you can or need to use a hook to inject your desired functionality. You can use one in the site/ready.php like this:

    $wire->addHookAfter('Pages::saved', null, function(HookEvent $event) {
        $page = $event->arguments(0);

		// now, after you have the page related to the hook event, check if it belongs to the pages / templates you want to process
		if('my-desired-templatename' != $page->template->name) return;

		if(!$page->mycheckbox_use_github) return;

		// after you definetly know that you want to process this page, execute what you want to ...

	});

Maybe a little OT, but also maybe useful for inspiration: 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@kongondo, thanks.
2. It isn't but it could be.

@horst, that module looks like a gem. Thank you.

@gmclelland, I'm sure it will help me.

Thanks guys. I do have a better ideia about what can be done and I'll try it in the coming days.

 

 

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...