thunderbird / thunderbird-website

Build code for the websites on thunderbird.net and start.thunderbird.net
https://www.thunderbird.net
149 stars 77 forks source link

Pull Request Preview Environments #456

Open MelissaAutumn opened 1 year ago

MelissaAutumn commented 1 year ago

Woah! I finished this? Wild.

You can see a preview of this on my local repo: https://github.com/MelissaAutumn/thunderbird-website/pull/1

This PR brings preview environments to thunderbird-website! Simply attach the preview environment label to a PR, and in like 7 minutes you'll have a live instance of that PR. If the PR is updated, the workflow will re-run and generate two new instances and clean up the old ones. If you unattach the label or delete the PR it should also clean up.

Cleaning up is powered by tagging everything in AWS. I create a unique id derived from a particular PR, and use that to lookup specific resources to nuke before generating new instances (or not depending on if we're closing a PR.)

I may have overlooked a specific resource to be cleaned up but we can fix that later. The repository should clean up any images older than 7 days automatically.

I setup our preview.thunderbird.dev to wildcard to the load balancer used. And the target groups for that load balancer directs the user to the correct fargate instance. (That was a pain to setup.)

There should be a user setup with the required permissions, but I may have missed one here or there. The task definitions should be created on upload, so don't worry about that.

Most importantly, this artfully crafts artisanal subdomains via a random name library, and a custom list of bird species I've scoured wikipedia for. (Do we need to attribute that?)

I believe I've updated all the hardcoded references, apologies if I didn't.

You'll need to setup the following secrets:

I've named everything with preview-env, so look for those :smile:

I'll answer any particular questions when I'm able to, but it may be a bit.

bogomil commented 8 months ago

That's a pure gold. Can we have this merged please! Thanks @MelissaAutumn