Set up a cron job to periodically redeploy a static site

I’m wondering if it’s possible to somehow configure render to trigger a periodic automatic static site redeploy.

The cron job feature appears to potentially be the way, but I’m not entirely sure what command to use to get it to work.

[FYI the bash script link on the cron job page is broken.]

Thank you

Hi,

You could have the Cron Job run a curl command that makes a request to your Static Site Deploy Hook.

I’m seeing the “bash script” link in point 2 of the Cron Command section, (which goes to tldp.org), as working. Or did you mean a different link?

Alan

You could have the Cron Job run a curl command that makes a request to your Static Site Deploy Hook.

I did that, but the build on the static site immediately triggered on saving the cron job and the build failed when executing the build command in the cron job. I’m not sure if there are other fields I’m not setting up correctly.

I also don’t exactly understand the logic of the “build command” field within the cron job settings? Would the cron command not just execute the build command in the static site settings when the webhook is triggered?

I’m seeing the “bash script” link in point 2 of the Cron Command section, (which goes to tldp.org), as working. Or did you mean a different link?

That’s the one I meant. It wouldn’t load for me, but I’ll try it again.

Services are separate. While they can use the same repo, the Static Site & Cron Job would not be directly linked. The Cron Job has a Build Command, to set up the job environment as you need. For example, if your job was a Node script, that required a certain npm package, the Cron Job Build Command would be npm install at the very least.

With my previous suggestion, the Cron Job isn’t actually going to be using the connected repo.

  • The Build Command could be echo "No Build Required"

  • The Command would be curl https://api.render.com/deploy/srv-xxxxxxxxx?key=<SECRET_KEY>

Alan

Excellent, thank you so much for the insight!

Just as a follow up, is there something I missed in the docs regarding the echo “No Build Required” command in the build command field? Or is that related to needing more knowledge on how linux servers function in general?

A Build Command is required for a Cron Job and most of the time that will be dependency install and or/a build script. You could have just used npm install for the same result, but to avoid a couple of seconds of unnecessary dependency installs I used a simple shell command. A Build Command can be any shell command, so we can’t really document them all. The build step is simply looking for the specified command to run and exit successfully.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.