Skip to content

Commit 8032253

Browse files
chore(patch): move exposed secret to .env file and 1password
1 parent 0ac1fea commit 8032253

File tree

8 files changed

+31
-2
lines changed

8 files changed

+31
-2
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.env.example
12
.github
23
.nyc_output
34
dist/

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MOESIF_APPLICATION_ID=op://serverest-ci-cd/moesif/application_id

.github/workflows/continuous_delivery.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
concurrency: create_release
4141

4242
runs-on: ubuntu-22.04
43-
environment: production
4443

4544
steps:
4645
- name: Project checkout
@@ -59,6 +58,11 @@ jobs:
5958
DOCKER_REGISTRY_USER: op://serverest-ci-cd/docker/username
6059
DOCKER_REGISTRY_PASSWORD: op://serverest-ci-cd/docker/password
6160
PACT_BROKER_TOKEN: op://serverest-ci-cd/pactflow/pact_broker_token
61+
MOESIF_APPLICATION_ID: op://serverest-ci-cd/moesif/application_id
62+
- name: Fill .env file with secrets
63+
run: echo "MOESIF_APPLICATION_ID=$MOESIF_APPLICATION_ID" >> .env
64+
env:
65+
MOESIF_APPLICATION_ID: ${{ env.MOESIF_APPLICATION_ID }}
6266
- name: Release on NPM and Docker
6367
6468
env:

.github/workflows/deploy-online-serverest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@ jobs:
5050
needs: build-and-push-image-to-gcloud-container-registry
5151

5252
runs-on: ubuntu-22.04
53+
environment: staging
5354

5455
steps:
5556
- name: Load secrets from 1password
5657
uses: 1password/load-secrets-action@v1
5758
env:
5859
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
5960
GCP_IAM_SERVICE_ACCOUNT_KEY: op://serverest-ci-cd/google-cloud/service_account_key
61+
MOESIF_APPLICATION_ID: op://serverest-ci-cd/moesif/application_id
62+
- name: Fill .env file with secrets
63+
run: echo "MOESIF_APPLICATION_ID=$MOESIF_APPLICATION_ID" >> .env
64+
env:
65+
MOESIF_APPLICATION_ID: ${{ env.MOESIF_APPLICATION_ID }}
6066
- name: Set up Cloud SDK
6167
uses: google-github-actions/setup-gcloud@v0
6268
- name: Authentication on GCloud
@@ -122,6 +128,7 @@ jobs:
122128
if: "!contains(github.ref, 'beta')"
123129

124130
runs-on: ubuntu-22.04
131+
environment: production
125132

126133
steps:
127134
- name: Load secrets from 1password

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ coverage.lcov
1717
.vscode/
1818

1919
## Others
20+
.env
2021
tmp/
2122
*.tmp
2223
*.swp

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"serverest": "src/server.js"
1010
},
1111
"files": [
12+
".env",
1213
"docs/",
1314
"src/"
1415
],
@@ -50,6 +51,7 @@
5051
"connect-timeout": "^1.9.0",
5152
"cors": "^2.8.5",
5253
"debug": "^4.3.4",
54+
"dotenv": "^16.3.1",
5355
"express": "^4.17.1",
5456
"express-async-errors": "^3.1.1",
5557
"express-query-int": "^3.0.0",

src/utils/logger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ para não ser afetado pelo teste de mutação.
77
Esse arquivo está marcado para ser ignorado no arquivo stryker.conf.js
88
*/
99

10+
require('dotenv').config()
1011
const moesif = require('moesif-nodejs')
1112

1213
const { version } = require('../../package.json')
@@ -21,7 +22,7 @@ module.exports = async app => {
2122
}
2223
const { porta, timeout, nodoc, nobearer, nosec } = require('../server').argv
2324
const moesifMiddleware = moesif({
24-
applicationId: 'eyJhcHAiOiIxNTA6MTU1MCIsInZlciI6IjIuMCIsIm9yZyI6IjQ5MToxMTIxIiwiaWF0IjoxNTk4OTE4NDAwfQ.e0E6Qhz1o1Jjs5prulHDYEBlv0juruWs_btjq2mong8',
25+
applicationId: process.env.MOESIF_APPLICATION_ID,
2526
identifyUser: (req, res) => { return formaDeExecucao() },
2627
identifyCompany: (req, res) => { return version },
2728
skip: (req, res) => {

0 commit comments

Comments
 (0)