Conditional to check the build day to prevent deploys on Fri/Sat/Sun

I looked at the current build conditionals and I did not see one that use the day of the week.

We’d like to prompt users if the build day is a Fri/Sat/Sun. If the user hits the “OK” button, then the build should carry on. If not, it should early end the build.

Hey @lymandetl!

Yeah, unfortunately you’re right, we don’t support days of the week with build conditionals. There are some ways around that though!

There may be other community solutions, but the one that I’ve come up with leverages off Buildkite’s dynamic pipeline generation functionality.

I created this gist with a script called check-day.sh that dynamically generates a pipeline, and inserts an additional block step if it’s a weekend day (Fri, Sat or Sun).

In my pipeline, I’ve set the repository to the gist, then running a command to change the permissions on the file and then piping its output to pipeline upload:

steps:
  - command: "chmod 755 check-day.sh && ./check-day.sh | buildkite-agent pipeline upload"

I hope this workaround helps! I’m only doing the permission change thing because I wanted to get it working just from a gist. End result looked like this:

1 Like