-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read secrets from .json file, and fetch from datastore for appengine (#…
…127)
- Loading branch information
1 parent
c3599de
commit 0b09f01
Showing
6 changed files
with
613 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
secrets.json | ||
|
||
node_modules/ | ||
.DS_Store | ||
.nyc_output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// istanbul ignore file | ||
|
||
'use strict' | ||
|
||
const {Datastore} = require('@google-cloud/datastore'); | ||
const fs = require('fs'); | ||
|
||
async function fetchSecret(tokenName) { | ||
const datastore = new Datastore({projectId: 'wpt-pr-bot'}); | ||
const key = datastore.key(['Token', tokenName]); | ||
let entity = await datastore.get(key); | ||
return entity[0].Secret; | ||
} | ||
|
||
(async () => { | ||
const secrets = { | ||
webhookSecret: await fetchSecret('github-webhook-secret'), | ||
githubToken: await fetchSecret('wpt-pr-bot-github-token'), | ||
}; | ||
await fs.promises.writeFile('secrets.json', JSON.stringify(secrets), 'utf8'); | ||
})().catch((reason) => { console.error(reason); process.exit(1) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.