Skip to content

Commit

Permalink
fix: remove stage-specific .env vars; pass via command during CI instead
Browse files Browse the repository at this point in the history
  • Loading branch information
brettstack committed May 6, 2020
1 parent db605ca commit 92ed71b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .env.production

This file was deleted.

2 changes: 0 additions & 2 deletions .env.staging

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/delete-stack-on-pr-close.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:
aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }}" > ~/.aws/credentials
- name: Delete PR preview stack
run: SERVERLESS_SERVICE_SUFFIX=${{ github.head_ref }} npm run remove-stack:dev
run: SERVERLESS_SERVICE_SUFFIX=-${{ github.head_ref }} npm run remove-stack:dev

8 changes: 2 additions & 6 deletions .github/workflows/on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: lsla
run: ls -la && ls -la packages && ls -la packages/ui

- name: Install package
run: |
(npm ci && npm audit --audit-level high && npm test) & \
(cd packages/ui && npm ci && npm audit --audit-level high && npm test) & \
(cd packages/api && npm ci && npm audit --audit-level high && npm test)
- name: Copy example.env.development to .env
run: cp example.env.development .env

- name: Deploy to sandboxed stack
id: deploy_to_sandboxed_stack
run: |
Expand All @@ -44,7 +40,7 @@ jobs:
aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }}" > ~/.aws/credentials
# TODO: How to also get the PR origin repo if it's coming from an external contributor
# See: env.GITHUB_REF, env.GITHUB_HEAD_REF, GITHUB_BASE_REF https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
NODE_ENV=production SERVERLESS_SERVICE_SUFFIX=-${{ github.head_ref }} npm run deploy:dev
NODE_ENV=production ALARMS_NOTIFICATION_EMAIL=alert@example.com SERVERLESS_SERVICE_SUFFIX=-${{ github.head_ref }} npm run deploy:dev
WEBSITE_URL=https://$(grep -o 'DefaultDomain": "[^"]*' ./stack-outputs.json | grep -o '[^"]*$')
echo "::set-output name=websiteUrl::$WEBSITE_URL"
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/on-push-to-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ jobs:
(cd packages/ui && npm ci && npm audit --audit-level high && npm test) & \
(cd packages/api && npm ci && npm audit --audit-level high && npm test)
- name: Copy example.env.development to .env
run: cp example.env.development .env

- name: Deploy to staging
run: |
mkdir ~/.aws
echo "[myapp_staging]
aws_access_key_id = ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }}" > ~/.aws/credentials
NODE_ENV=production SERVERLESS_SERVICE_SUFFIX='' npm run deploy:staging
NODE_ENV=production npm run deploy:staging
# TODO: Additional end-to-end tests

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Make a copy of the `example.env.development` file:
cp example.env.development .env.development
```

Modify the values in your `.env.development` file.
Modify the values in your `.env.development` file. If you're using a shared developer account, you should set `SERVERLESS_SERVICE_SUFFIX=-brett`, ensuring the value you specify is unique and not used by other developers on your team.

Run `npm run deploy:dev` to deploy to your dev account.

Expand Down
2 changes: 1 addition & 1 deletion example.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SERVERLESS_SERVICE_SUFFIX=-myname
SERVERLESS_SERVICE_SUFFIX=
ALARMS_NOTIFICATION_EMAIL=alert@example.com
5 changes: 2 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
"typeface-roboto": "0.0.75"
},
"scripts": {
"start-cloud-api": "npm run cp-stack-outputs && react-scripts start",
"start": "npm run cp-stack-outputs && react-scripts start",
"cp-stack-outputs": "echo 1 || cp ../../stack-outputs.json ./src",
"start-cloud-api": "react-scripts start",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down

0 comments on commit 92ed71b

Please sign in to comment.