itsjoshbruce,
@itsjoshbruce@phpc.social avatar

I have an affinity for: Wait until the last responsible moment.

I've been contemplating Continuous Deployment on my personal site for years: https://joshbruce.com

But, before I did, I embraced the @jezhumble line: If it hurts, do it more often, and bring the pain forward.

I could deploy my sites in less than a minute using my phone by the time I hit the ceiling of the manual process I used.

Becca and I are ramping up on TIA: https://the-irreverent-agilists.com



itsjoshbruce, (edited )
@itsjoshbruce@phpc.social avatar

Becca needs to be able to add content to the TIA site without waiting for me to finish her flow.

So, being a pull-based human (preferring to wait until pulled enough to action) and perfectly willing to take on responsibility (friction) for my own stuff, I set to work.

The optimized (happy path) process looked like this:

  1. Clone repo
  2. Edit content
  3. Submit PR (don't @ me)
  4. Let Continuous Integration pass
  5. Merge
  6. Launch a command line app
  7. cd into the remote repo
  8. git pull

Done

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

Becca is content with doing steps 1 through 5. So, no pull to start creating an admin panel - because that's usually where the bulk of the code lives (and most bugs).

So, we're talking about automating steps 6 through 8.

I used the base found here: https://eric.blog/2022/09/04/simple-github-webhook-handler-in-php/

It's conceptual, and a lightweight explanation and just what I needed to start and then run with it.

itsjoshbruce, (edited )
@itsjoshbruce@phpc.social avatar

I started with a public repo: https://github.com/8fold/site-joshbruce.com

For this site: https://joshbruce.com

Because I figured it would be the easiest. It was.

Then I decided to see if I could do two different repos and sites hosted on the same server and user directory.

That led me to the calling card site: https://itsjoshbruce.com

And, another public repo: https://github.com/8fold/site-itsjoshbruce.com

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

Last but not least, the TIA site.

It's a private repo, so no link.

It's on the same server but a different user directory.

So, I cloned the php-deployer script and set up an environment file (using JSON, not .ENV).

Then I did what feels like the clunky part; setting up GitHub webhooks, mainly because I'm using tokens specific to the repo doing the push.

And voila: https://the-irreverent-agilists.com

If you'd be interested in a longer (and more in-depth) write-up on how I did this, let me know.

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

It's worth noting I could have done it through GitHub Actions, but I decided against that.

In part because I don't want to be even more tightly coupled to GitHub and its infrastructure.

If I switch to some other remote Git solution, if it has webhooks, I should be able to update the script in short order (there are zero dependencies for the script I wrote, and CI through GitHub Actions says it would work in PHP 7.3, I haven't tried going farther back).

That was my Saturday. How was yours?

itsjoshbruce,
@itsjoshbruce@phpc.social avatar

ps. The time from merge to visible so far has been less than 1 second. (Locally, the script runs in about 300ms and uses one exec call.)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • khanakhh
  • InstantRegret
  • rosin
  • Youngstown
  • ngwrru68w68
  • mdbf
  • slotface
  • normalnudes
  • Durango
  • kavyap
  • everett
  • cubers
  • megavids
  • GTA5RPClips
  • ethstaker
  • thenastyranch
  • osvaldo12
  • Leos
  • tester
  • tacticalgear
  • cisconetworking
  • modclub
  • anitta
  • provamag3
  • JUstTest
  • lostlight
  • All magazines