Skip to content

Commit fdee785

Browse files
Update from template. (#36)
Enables use of CircleCI contexts for CI credentials.
1 parent 8a35822 commit fdee785

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

.circleci/config.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
1-
version: 2
1+
version: 2.1
22

33
defaults: &defaults
44
working_directory: ~/repo
55
docker:
6-
- image: circleci/node:12.16.2
6+
- image: cimg/node:14.19
7+
8+
_steps:
9+
restore_npm_cache: &restore_npm_cache
10+
restore_cache:
11+
keys:
12+
- npm-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}
13+
- npm-v1-{{ .Branch }}-
14+
- npm-v1-
15+
save_npm_cache: &save_npm_cache
16+
save_cache:
17+
paths:
18+
- .npm-cache
19+
key: npm-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}
20+
configure_registry_auth: &configure_registry_auth
21+
run:
22+
name: Configure registry auth
23+
command: echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/repo/.npmrc
724

825
jobs:
926
test:
1027
<<: *defaults
1128
steps:
1229
- checkout
13-
- restore_cache:
14-
keys:
15-
- v1-dependencies-{{ checksum "package-lock.json" }}
16-
# fallback to using the latest cache if no exact match is found
17-
- v1-dependencies-
18-
- run: npm ci
30+
- *restore_npm_cache
31+
- *configure_registry_auth
32+
- run: npm ci --cache .npm-cache
1933
- run:
2034
name: Run coverage tests
2135
command: npm run test:coverage
2236
- run:
2337
name: Run build
2438
command: npm run build
25-
- save_cache:
26-
paths:
27-
- node_modules
28-
key: v1-dependencies-{{ checksum "package-lock.json" }}
2939
- persist_to_workspace:
3040
root: ~/repo
3141
paths: .
3242
- store_artifacts:
3343
path: ~/repo/dist
44+
- *save_npm_cache
3445
deploy:
3546
<<: *defaults
3647
steps:
3748
- attach_workspace:
3849
at: ~/repo
39-
- run:
40-
name: Configure registry auth
41-
command: echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/repo/.npmrc
50+
- *configure_registry_auth
4251
- run:
4352
name: Publish package
4453
# For now we only publish on tags here and assume the version number is already correct.
@@ -50,10 +59,14 @@ workflows:
5059
test-deploy:
5160
jobs:
5261
- test:
62+
context:
63+
- "NPM Read"
5364
filters:
5465
tags:
5566
only: /^v.*/
5667
- deploy:
68+
context:
69+
- "NPM Write"
5770
requires:
5871
- test
5972
filters:

0 commit comments

Comments
 (0)