Skip to content

Commit da6f860

Browse files
authored
chore: issue 487. clarify "named" branches vs. others (#553)
* chore: issue 487. Adding info on named branches. * chore: issue 487. Testing comment. * chore: issue 487. Updating rest of readmes. * chore: per morgante's comment * chore: changing to "named environment branch" everywhere
1 parent e193a6d commit da6f860

File tree

6 files changed

+59
-19
lines changed

6 files changed

+59
-19
lines changed

1-org/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,15 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to see
169169
git add .
170170
git commit -m 'Your message'
171171
```
172-
1. Push your plan branch to trigger a plan. For this command, the branch `plan` is not a special one. Any branch which name is different from `development`, `non-production` or `production` will trigger a Terraform plan.
172+
1. Push your plan branch to trigger a plan for all environments. Because the
173+
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
174+
branch triggers _terraform plan_ but not _terraform apply_.
173175
```
174176
git push --set-upstream origin plan
175177
```
176178
1. Review the plan output in your Cloud Build project. https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
177-
1. Merge changes to production branch.
179+
1. Merge changes to production branch. Because the _production_ branch is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
180+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
178181
```
179182
git checkout -b production
180183
git push origin production
@@ -239,7 +242,7 @@ to run the command as the Terraform service account.
239242
git add .
240243
git commit -m 'Your message'
241244
```
242-
1. Push your plan branch. The branch `plan` is not a special one. Any branch which name is different from `development`, `non-production` or `production` will trigger a Terraform plan.
245+
1. Push your plan branch.
243246
- Assuming you configured an automatic trigger in your Jenkins Master (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](http://www.jenkins.io) for more details.
244247
```
245248
git push --set-upstream origin plan

2-environments/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,29 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
103103
git add .
104104
git commit -m 'Your message'
105105
```
106-
1. Push your plan branch to trigger a plan for all environments.
106+
1. Push your plan branch to trigger a plan for all environments. Because the
107+
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
108+
branch triggers _terraform plan_ but not _terraform apply_.
107109
```
108110
git push --set-upstream origin plan
109111
```
110112
1. Review the plan output in your cloud build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
111-
1. Merge changes to development.
113+
1. Merge changes to development branch. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
114+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
112115
```
113116
git checkout -b development
114117
git push origin development
115118
```
116119
1. Review the apply output in your cloud build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
117-
1. Merge changes to non-production.
120+
1. Merge changes to non-production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
121+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
118122
```
119123
git checkout -b non-production
120124
git push origin non-production
121125
```
122126
1. Review the apply output in your cloud build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
123-
1. Merge changes to production branch.
127+
1. Merge changes to production branch. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
128+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
124129
```
125130
git checkout -b production
126131
git push origin production

3-networks/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,31 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
155155
1. Run `terraform plan` and review output.
156156
1. Run `terraform apply`.
157157
1. If you would like the bucket to be replaced by Cloud Build at run time, change the bucket name back to `UPDATE_ME`.
158-
1. Push your plan branch to trigger a plan.
158+
1. Push your plan branch to trigger a plan for all environments. Because the
159+
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
160+
branch triggers _terraform plan_ but not _terraform apply_.
159161
```
160162
git push --set-upstream origin plan
161163
```
162164
1. Review the plan output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
163-
1. Merge changes to production.
165+
1. Merge changes to production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
166+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
164167
```
165168
git checkout -b production
166169
git push origin production
167170
```
168171
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
169172
1. After production has been applied, apply development.
170-
1. Merge changes to development.
173+
1. Merge changes to development. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
174+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
171175
```
172176
git checkout -b development
173177
git push origin development
174178
```
175179
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
176180
1. After development has been applied, apply non-production.
177-
1. Merge changes to non-production.
181+
1. Merge changes to non-production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
182+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
178183
```
179184
git checkout -b non-production
180185
git push origin non-production

4-projects/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,26 +159,31 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
159159
git add .
160160
git commit -m 'Your message'
161161
```
162-
1. Push your plan branch to trigger a plan.
162+
1. Push your plan branch to trigger a plan for all environments. Because the
163+
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
164+
branch triggers _terraform plan_ but not _terraform apply_.
163165
```
164166
git push --set-upstream origin plan
165167
```
166168
1. Review the plan output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
167-
1. Merge changes to production.
169+
1. Merge changes to production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
170+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
168171
```
169172
git checkout -b production
170173
git push origin production
171174
```
172175
1. Review the apply output in your Cloud Build project. https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
173176
1. After production has been applied, apply development.
174-
1. Merge changes to development.
177+
1. Merge changes to development. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
178+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
175179
```
176180
git checkout -b development
177181
git push origin development
178182
```
179183
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
180184
1. After development has been applied, apply non-production.
181-
1. Merge changes to non-production.
185+
1. Merge changes to non-production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
186+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
182187
```
183188
git checkout -b non-production
184189
git push origin non-production

5-app-infra/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,29 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
149149
git add .
150150
git commit -m 'Your message'
151151
```
152-
1. Push your plan branch to trigger a plan for all environments.
152+
1. Push your plan branch to trigger a plan for all environments. Because the
153+
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
154+
branch triggers _terraform plan_ but not _terraform apply_.
153155
```
154156
git push --set-upstream origin plan
155157
```
156158
1. Review the plan output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_INFRA_PIPELINE_PROJECT_ID
157-
1. Merge changes to development.
159+
1. Merge changes to development. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
160+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
158161
```
159162
git checkout -b development
160163
git push origin development
161164
```
162165
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_INFRA_PIPELINE_PROJECT_ID
163-
1. Merge changes to non-production.
166+
1. Merge changes to non-production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
167+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
164168
```
165169
git checkout -b non-production
166170
git push origin non-production
167171
```
168172
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_INFRA_PIPELINE_PROJECT_ID
169-
1. Merge changes to production branch
173+
1. Merge changes to production branch. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
174+
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
170175
```
171176
git checkout -b production
172177
git push origin production

docs/FAQ.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,20 @@ We recommend that your request 50 additional projects for the service account, `
1010
You can use the [Request Project Quota Increase](https://support.google.com/code/contact/project_quota_increase) form to request the quota increase.
1111
In the support form, for **Email addresses that will be used to create projects**, use the `terraform_service_account` address that's created in the organization bootstrap module.
1212
If you see other quota errors, see the [Quota documentation](https://cloud.google.com/docs/quota).
13+
14+
## What is a "named" branch?
15+
16+
Certain branches in the terraform-example-foundation are considered to be
17+
_named branches_. Pushing to a named branch causes the _apply_ command to be
18+
run. Pushing to branches other than the named branches does not run _apply_.
19+
20+
* development
21+
* non-production
22+
* production
23+
24+
## Which Terraform commands are run when I push to a branch?
25+
26+
If you pushed to a _named branch_ the following commands are run: _init_, _plan_, _validate_, _apply_.
27+
28+
If you push to a branch that is not a named branch, only _init_, _plan_, and
29+
_validate_ are run. The _apply_ command is not run.

0 commit comments

Comments
 (0)