Skip to content

Commit 1d37bf9

Browse files
committed
Removed templating from circleci config
1 parent 294808d commit 1d37bf9

2 files changed

Lines changed: 13 additions & 94 deletions

File tree

.circleci/README.md

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,10 @@ Requires you to configure the below [CircleCI Environment Variables](https://cir
88

99
- AWS_DEFAULT_REGION # Region of your cluster
1010
- AWS_ECR_ACCOUNT_URL # {awsAccountNum}.dkr.ecr.{region}.amazonaws.com
11+
- AWS_ECR_REPO_NAME # The ECR repository name to write images to
12+
- PRODUCTION_EKS_CLUSTER_NAME # The name of the production EKS cluster to deploy into
13+
- STAGING_EKS_CLUSTER_NAME # The name of the staging EKS cluster to deploy into
1114

12-
Required if you have one aws account per environment:
13-
- AWS_ECR_REPO_ACCOUNT_ID # AWS account id of the account that contains the ECR repo to use
14-
- AWS_CLUSTER_AUTH_ROLE_ARN_STAGING # ARN of the role for the circleci user to assume in staging
15-
- AWS_CLUSTER_AUTH_ROLE_ARN_PRODUCTION # ARN of the role for the circleci user to assume in production
16-
17-
### Parameters
18-
19-
#### language
20-
21-
Options:
22-
23-
- go
24-
- nodejs
25-
26-
Note: Don't see your language here? Add a pull request. Templates are written using the [Go Templating Language](https://golang.org/pkg/text/template/).
27-
28-
##### assumeRole
29-
30-
Boolean to use the AWS assume role or not. Role you assume is based on clusterAuthenitcationRoleArn.
31-
You'll need to provide the env vars above if this is true.
32-
33-
##### circleCIPro
34-
35-
If you've got a Performance account with CircleCI enable this for faster docker builds.
36-
37-
##### stagingClusterName
38-
39-
The name of the staging EKS cluster.
40-
41-
##### productionClusterName
42-
43-
The name of the production EKS cluster.
44-
45-
46-
### Example
47-
48-
See our [example config](commit0.example.yml) for usage.
4915

5016
## Deployment Process
5117

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ orbs:
1111

1212
variables:
1313
- &workspace /home/circleci/project
14-
<% if (index .Params `language`) and eq index .Params `language` "go" %>
14+
1515
- &build-image cimg/go:1.13
16-
<% else if (index .Params `language`) and eq index .Params `language` "nodejs" %>
17-
- &build-image cimg/node:12.6
18-
<% else %>
19-
- &build-image cimg/base:2020.01
20-
<% end %>
16+
2117

2218
aliases:
2319
# Shallow Clone - this allows us to cut the 2 minute repo clone down to about 10 seconds for repos with 50,000 commits+
@@ -83,16 +79,6 @@ aliases:
8379
git reset --hard "$CIRCLE_SHA1"
8480
pwd
8581
86-
<% if index .Params `assumeRole` %>
87-
- &assume-role
88-
name: Assume role
89-
command: |
90-
RESULT=$(aws sts assume-role --role-arn << parameters.cluster-authentication-role-arn >> --role-session-name deploy)
91-
aws configure set aws_access_key_id "$(echo $RESULT | jq -r .Credentials.AccessKeyId)" --profile assumed-role
92-
aws configure set aws_secret_access_key "$(echo $RESULT | jq -r .Credentials.SecretAccessKey)" --profile assumed-role
93-
aws configure set aws_session_token "$(echo $RESULT | jq -r .Credentials.SessionToken)" --profile assumed-role
94-
<% end %>
95-
9682
- &install-binaries
9783
name: Install Binaries
9884
command: |
@@ -128,40 +114,21 @@ jobs:
128114

129115
- restore_cache: # restores saved cache if no changes are detected since last run
130116
keys:
131-
<% if (index .Params `language`) and eq index .Params `language` "go" %>
132117
- v1-pkg-cache-{{ checksum "go.sum" }}
133-
<% else if (index .Params `language`) and eq index .Params `language` "nodejs" %>
134-
- v1-pkg-cache-{{ checksum "package-lock.json" }}
135-
<% end %>
136118
- v1-pkg-cache-
137119
- run:
138120
name: Run unit tests
139121
command: |
140-
<% if (index .Params `language`) and eq index .Params `language` "go" %>
141122
go get -u github.com/jstemmer/go-junit-report
142123
mkdir -p test-reports
143124
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
144125
echo "Tests: $PACKAGE_NAMES"
145126
go test -v $PACKAGE_NAMES | go-junit-report > test-reports/junit.xml
146-
<% else if (index .Params `language`) and eq index .Params `language` "nodejs" %>
147-
npm test
148-
<% else %>
149-
# Add your command to run unit tests here.
150-
<% end %>
151-
152127
153128
- save_cache: # Store cache in the /go/pkg directory
154-
<% if (index .Params `language`) and eq index .Params `language` "go" %>
155129
key: v1-pkg-cache-{{ checksum "go.sum" }}
156-
<% else if (index .Params `language`) and eq index .Params `language` "nodejs" %>
157-
key: v1-pkg-cache-{{ checksum "package-lock.json" }}
158-
<% end %>
159130
paths:
160-
<% if (index .Params `language`) and eq index .Params `language` "go" %>
161131
- "/go/pkg"
162-
<% else if (index .Params `language`) and eq index .Params `language` "nodejs" %>
163-
- "node_modules"
164-
<% end %>
165132

166133
- store_test_results:
167134
path: test-reports
@@ -174,29 +141,15 @@ jobs:
174141

175142
build_and_push:
176143
machine:
177-
docker_layer_caching: <% if index .Params `circleCIPro` %>true<% else %>false<% end %> # only for performance plan circleci accounts
144+
docker_layer_caching: false # only for performance plan circleci accounts
178145
steps:
179146
- attach_workspace:
180147
at: *workspace
181148
- run: *checkout-shallow
182149
- version-tag/create
183-
<% if index .Params `assumeRole` %>
184-
- aws-cli/install
185-
- aws-cli/setup
186-
- aws-ecr/ecr-login-for-secondary-account:
187-
account-id: AWS_ECR_REPO_ACCOUNT_ID
188-
region: AWS_DEFAULT_REGION
189-
- aws-ecr/build-image:
190-
repo: <% .Name %>
191-
tag: $VERSION_TAG,latest
192-
- aws-ecr/push-image:
193-
repo: <% .Name %>
194-
tag: $VERSION_TAG,latest
195-
<% else %>
196150
- aws-ecr/build-and-push-image:
197-
repo: <% .Name %>
151+
repo: ${AWS_ECR_REPO_NAME}
198152
tag: $VERSION_TAG,latest
199-
<% end %>
200153

201154
deploy:
202155
executor: aws-eks/python3
@@ -281,10 +234,10 @@ workflows:
281234

282235
- deploy:
283236
name: deploy_staging
284-
repo: "<% .Name %>"
285-
cluster-name: "<% index .Params `stagingClusterName` %>"
237+
repo: "${AWS_ECR_REPO_NAME}"
238+
cluster-name: "${STAGING_EKS_CLUSTER_NAME}"
286239
config-environment: "staging"
287-
<% if index .Params `assumeRole` %>cluster-authentication-role-arn: "${AWS_CLUSTER_AUTH_ROLE_ARN_STAGING}"<% end %>
240+
cluster-authentication-role-arn: "${AWS_CLUSTER_AUTH_ROLE_ARN_STAGING}"
288241
region: "${AWS_DEFAULT_REGION}"
289242
namespace: "${CIRCLE_BRANCH}"
290243
tag: "${VERSION_TAG}"
@@ -303,10 +256,10 @@ workflows:
303256

304257
- deploy:
305258
name: deploy_production
306-
repo: "<% .Name %>"
307-
cluster-name: "<% index .Params `productionClusterName` %>"
259+
repo: "${AWS_ECR_REPO_NAME}"
260+
cluster-name: "${PRODUCTION_EKS_CLUSTER_NAME}"
308261
config-environment: "production"
309-
<% if index .Params `assumeRole` %>cluster-authentication-role-arn: "${AWS_CLUSTER_AUTH_ROLE_ARN_PRODUCTION}"<% end %>
262+
cluster-authentication-role-arn: "${AWS_CLUSTER_AUTH_ROLE_ARN_PRODUCTION}"
310263
region: "${AWS_DEFAULT_REGION}"
311264
namespace: "${CIRCLE_BRANCH}"
312265
tag: "${VERSION_TAG}"

0 commit comments

Comments
 (0)