How I Got My Netlify Site to Auto-Deploy
This site runs on Hugo because, well, static site generators are just so damn convenient when you don’t need anything fancy. It’s fast, there are tons of great templates out there, and I’ve even made my own theme when I got bored one weekend (check it out here if you’re curious).
For hosting, I went with Netlify. Their free tier is ridiculously generous - this little blog isn’t exactly bringing in Netflix-level traffic - and they’ve got Hugo support baked right in. The standard setup works great: push to GitHub, Netlify detects the change, builds everything, and boom - site updated in under a minute.
But here’s where I ran into a snag. I’m not one of those organized people who write and publish posts in one sitting. I’ll chip away at drafts over days, schedule them for future dates, and then completely forget about them. The problem? Netlify doesn’t build future-dated posts (which makes total sense). This meant that when a post’s publish date finally rolled around, it wouldn’t actually appear on my site until I manually triggered a rebuild.
And let’s be real - if I can’t even remember to finish writing a post in one go, I’m definitely not going to remember to manually deploy it on the right day. I needed to automate this nonsense.
Sure, Netlify probably has some fancy way to handle this with their paid plans, but my cheapskate brain immediately went to “how can I hack this together for free?”
Netlify Configuration
Turns out, it’s pretty straightforward! First, head over to your Netlify dashboard, go to site configuration > build & deploy > continuous deployment. Scroll down to “build hooks” and create one.
What you’ll get is a special URL that acts like a magic button - send a POST request to it, and Netlify will kick off a fresh build of your site. No GitHub commit required! This is exactly what I needed.
GitHub Action
Now for the automation part. Since my code already lives on GitHub, I figured GitHub Actions was the path of least resistance. Here’s the dead-simple YAML I put together:
|
|
The action does two things:
- It runs automatically at 1 AM every day (via the cron schedule) to deploy any posts that might have “gone live” that day
- It has a manual trigger (workflow_dispatch) so I can poke it if needed
The actual work is hilariously simple - it just makes an HTTP POST request to that Netlify hook URL. That’s it. That’s the entire solution.
Just paste your build hook URL where it says <YOUR ENDPOINT HERE>
, and you’re good to go. Hit the “Run workflow” button once to make sure everything’s working, and you should see a new deployment kick off in your Netlify dashboard.
Problem solved! Now I can be as absent-minded as I want about scheduling posts, and they’ll still show up without me having to remember anything. Sometimes the laziest solutions are the best ones.