Skip to content

Commit 1ddb35e

Browse files
committed
chore: use .env file for local credentials
1 parent bbce87a commit 1ddb35e

File tree

5 files changed

+66
-38
lines changed

5 files changed

+66
-38
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build/
1515

1616
# misc
1717
.DS_Store
18+
.env
1819
.env.local
1920
.env.development.local
2021
.env.test.local

Makefile

+17-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ all: test
1818

1919
ci: test $(DEPLOY_TARGET)
2020

21+
# Run the ci target as if we were on Travis CI
22+
fake_ci: .env
23+
CI=true \
24+
TRAVIS_COMMIT=`git rev-parse --short HEAD`+`date +%s` \
25+
TRAVIS_BRANCH=`git rev-parse --abbrev-ref HEAD` \
26+
REACT_APP_API_BASE_URL=http://localhost:8080 \
27+
make ci
28+
2129
## =====================
2230
## Build/test tasks
2331
## =====================
2432

25-
test:
33+
test: .env
2634
npm run test:pact
2735

2836
## =====================
@@ -34,8 +42,9 @@ deploy: can_i_deploy deploy_app tag_as_prod
3442
no_deploy:
3543
@echo "Not deploying as not on master branch"
3644

37-
can_i_deploy:
45+
can_i_deploy: .env
3846
@docker run --rm \
47+
--env-file .env \
3948
-e PACT_BROKER_BASE_URL \
4049
-e PACT_BROKER_TOKEN \
4150
pactfoundation/pact-cli:latest \
@@ -49,8 +58,9 @@ can_i_deploy:
4958
deploy_app:
5059
@echo "Deploying to prod"
5160

52-
tag_as_prod:
61+
tag_as_prod: .env
5362
@docker run --rm \
63+
--env-file .env \
5464
-e PACT_BROKER_BASE_URL \
5565
-e PACT_BROKER_TOKEN \
5666
pactfoundation/pact-cli:latest \
@@ -105,3 +115,7 @@ travis_login:
105115
# Requires PACT_BROKER_TOKEN to be set
106116
travis_encrypt_pact_broker_token:
107117
@docker run --rm -v ${HOME}/.travis:/root/.travis -v ${PWD}:${PWD} --workdir ${PWD} lirantal/travis-cli encrypt --pro PACT_BROKER_TOKEN="${PACT_BROKER_TOKEN}"
118+
119+
120+
.env:
121+
touch .env

package-lock.json

+45-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"eslint-plugin-jsx-a11y": "^6.2.3",
5050
"eslint-plugin-react": "^7.17.0",
5151
"eslint-plugin-react-hooks": "^1.7.0",
52-
"nock": "^11.7.2"
52+
"nock": "^11.7.2",
53+
"dotenv": "^8.2.0"
5354
}
5455
}

publish.pact.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require('dotenv').config()
12
const pact = require('@pact-foundation/pact-node');
23

34
if (process.env.CI !== 'true') {

0 commit comments

Comments
 (0)