NewCI/CD in 2023. Check out the December Release for usage metrics, platform improvements, and a sneak peek at upcoming features.

Building the world’s most over-engineered Secret Santa 🎄


I love an office Secret Santa:

  1. Buying a gift you’re not too sure about.
  2. Placing it nervously under the office Christmas tree.
  3. Sharing in the excitement as everyone unwraps their gifts.

But running a Secret Santa takes a surprising amount of coordination: creating a spreadsheet, listing the team members—and for remote teams—collecting delivery addresses. It’s always a task for that charitable person selflessly wrangling, fussing, and reminding everyone all the way to the crescendo of tearing gift wrap. They make sure everyone’s details are in, let each person know who they’re buying for, and keep everything secret (at least for everyone but themselves).

In the true spirit of a DevOps Christmas, what if we freed up this generous human’s time for more enjoyable things, like sipping warm spiced drinks, nibbling candy canes, and also being surprised along with the rest of their team? Let me present to you the world’s most over-engineered Secret Santa. Why? Because we can. Why rely on a simple spreadsheet and a few DMs, when we can spend days over-engineering a solution that uses a build pipeline to do it all for us!?

This might be the only Secret Santa to use a build pipeline with:

How does it work?

This festive build pipeline is generated using a Bash script.

#!/bin/bash set -euo pipefail NAMES=$(shuf -e Baz Ben Brett Chris Hannah Mel MHz Michael Mitch) if [[ ! -z "${BUILDKITE:-}" ]]; then   buildkite-agent meta-data set names "$NAMES" fi cat <<PIPELINE steps: - command: "pipeline/readme.bash" label: "🎄 README please" PIPELINE for name in $NAMES; do cat <<PIPELINE - block: "📝 $name" prompt: "Dear Secret Santa…" submit: "Lock it in Eddy!" fields: - text: "My xmas pressie hint"  key: "hint-$name" - text: "Please deliver my xmas pressie to this address" key: "address-$name" PIPELINE done cat <<PIPELINE - command: "pipeline/magical-unicorns.bash" label: "💌 :santa::skin-tone-3: :unicorn_face:" PIPELINE

This bash script creates:

  • An intro step to welcome everyone to this year’s Secret Santa.
  • Input steps for each team member listed in the NAMES array. The input fields collect everyone's present hints and postal addresses, which are available as build meta-data for subsequent steps.
  • An outro step to show a magical ASCII unicorn and asks everyone to check their email.

Once everyone has unblocked their input steps we have the information needed to proceed with Operation Secret Santa.

An AWS lambda function:

  • Accepts the job.finished webhook from Buildkite
  • Uses the job-event-processor.js to extract the answers people gave from the webhook’s build metadata
  • Randomly assigns each secret Santa—based on a deterministic seed value for safe re-execution using secret-santa.js. The seed is read from an environment variable so it can be changed at the last minute, to keep the "secret" in "Secret Santa"
  • Sends out emails to all our secret Santas using Amazon SES

To wrap this up 🎁

Our Secret Santa admin has now been replaced by a Lambda function and a CI pipeline and yours could be too! Check out the code on GitHub, adapt it for your team, auth into AWS, spin up some build agents, warm up your Lambdas, and make merry!

Shout out to Tim Lucas the Buildkite Secret Santa creator, whose repo I forked, and rekindled for XMAS 2023. 🎄✨