Discord Bot Pipeline - GitHub Setup
This post is part 3 of a 10 part series:
- Part 1 - Discord Bot Pipeline - Intro
- Part 2 - Discord Bot Pipeline - GCP Setup
- Part 3 - Discord Bot Pipeline - GitHub Setup (This Post)
- Part 4 - Discord Bot Pipeline - Terraform Setup
- Part 5 - Discord Bot Pipeline - GitHub Actions Setup
- Part 6 - Discord Bot Pipeline - Making Terraform Changes
- Part 7 - Discord Bot Pipeline - Discord Specific Terraform Setup
- Part 8 - Discord Bot Pipeline - More Setup
- Part 9 - Discord Bot Pipeline - Creating The Bot
- Part 10 - Discord Bot Pipeline - Conclusion
Previously in this series, we set up our GCP organization and created an admin project that will carry out Terraform actions. Now let’s set up a GitHub project to integrate with this GCP project. The goal here is to use GitHub workflows in order to manage your projects with Terraform. The details of Terraform are beyond the scope of this series, but the next section will provide a brief overview.
GitHub Setup
First, create a new GitHub project by navigating to https://github.com/new.
Create a project like terraform-controller
and clone it locally to your
machine. From the repository’s settings tab, go to Secrets and variables ->
Actions.
We are going to create three repository secrets that will be used by the
workflows to interact with Terraform and our GCP project. Click
New Repository secret
and add the following:
- GCP_BILLING_ACCOUNT_ID
- GCP_ORGANIZATION_ID
- GCP_SA_KEY
As in the previous step, your GCP billing account ID can be found by running:
gcloud beta billing accounts list --format=json \
| jq -r '.[0].name' \
| cut -d'/' -f2
And your organization ID can be found by running:
gcloud organizations list --format=json \
| jq -r '.[0].name' \
| cut -d'/' -f2
The service account was created in the previous step and stored in
~/.config/gcloud/<your domain>-tf-controller.json
. Copy the entire contents of
this file when creating the GCP_SA_KEY
secret. These steps are shown in the
gallery below. Note: I created these images with a different repository name but
the gist is the same.
We will be leveraging branch naming conventions in order to handle Terraform
operations. Our default branch is main
, which will contain workflows and
templates for a basic Terraform configuration. Each of our projects will be
handled by a branch with a prefix like _deploy
. So for a project like
discord-bots
, we will have a branch discord-bots_deploy
. This branch will be
used to apply Terraform configs specifically for our discord-bots
project. In
the next section, we will add the basic Terraform configurations necessary for
spinning up new projects using our infrastructure.