1. Resources
  2. /
  3. Blog
  4. /
  5. Building the world’s most over-engineered Secret Santa 🎄

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

3 minute read

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/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. 🎄✨


Related posts

Start turning complexity into an advantage

Create an account to get started with a 30-day free trial. No credit card required.

Buildkite Pipelines

Platform

  1. Pipelines
  2. Pipeline templates
  3. Public pipelines
  4. Test Engine
  5. Package Registries
  6. Mobile Delivery Cloud
  7. Pricing

Hosting options

  1. Self-hosted agents
  2. Mac hosted agents
  3. Linux hosted agents

Resources

  1. Docs
  2. Blog
  3. Changelog
  4. Webinars
  5. Plugins
  6. Case studies
  7. Events

Company

  1. About
  2. Careers
  3. Press
  4. Brand assets
  5. Contact

Solutions

  1. Replace Jenkins
  2. Workflows for AI/ML

Support

  1. System status
  2. Forum