Welcome hackathoners!
- Use a private repo!
You don't want to risk having anyone out there create merge requests that create stuff in your gcp project. - No secrets in the code!
This repo is used to quickly get you up to speed with deploying to your gcp project from github. If you're up to the task with also working with Terraform you can use this repo as a starting pointfor that as well.
The terraform module creates:
- pubsub topic
- service account
- permission for the service acount to publish to the pubsub topic
- Create a private repo in GitHub under your user name called terraform-google-cloud-build
- Mirror the supersmo/terraform-google-cloud-build repo to your new private repo by following these instructions:
Open Git Bash Create a variable for your username:
github_user=<your-github_user>
Change directory to where you want to create your repo (/c is c: if you're on windows) e.g.:
cd /c/ws/github.com
Create a bare clone of the repository:
git clone --bare https://github.com/supersmo/terraform-google-cloud-build.git
Mirror-push to the new repository:
git push --bare https://github.com/${github_user}/terraform-google-cloud-build.git
Remove the temporary local repository you created earlier.
cd ..
rm -rf terraform-google-cloud-build.git
Clone the repository:
git clone https://github.com/${github_user}/terraform-google-cloud-build.git
Git will use the username and e-mail stored in the git global config which probably already is configured to be your work e-mail. If you wish to change the commit username and email only for this repo:
cd terraform-google-cloud-build
git config user.name <your name>
git config user.email <your e-mail>
-
Log in to gcp and go to your gcp project: https://console.google.com
-
Log in to your GitHub account if you're not already logged in
- Edit the default push trigger to:
-
Create a trigger for the main branch by duplicating the trigger
-
Edit the duplicate trigger to only trigger on the main branch
-
Make a branch and push the branch to trigger a terraform plan
-
Inspect the plan in cloud build
-
If you are satisfied with the plan create a pull request to merge the branch to main.
-
Check the terraform apply log in cloud build
-
Navigate in your gcp project to see that the resources were created.