From 2f816cbd9f9ad02725328ac98dfa6fa39d4dd365 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Wed, 18 Mar 2020 12:45:33 +0100 Subject: [PATCH] Add ability to configure repos through environment variables --- .env.sample | 13 +++++++++++++ README.md | 7 +++++++ now.json | 5 +++++ rollup.config.js | 1 + src/index.js | 9 +-------- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.env.sample b/.env.sample index 56a270d..99870e4 100644 --- a/.env.sample +++ b/.env.sample @@ -1,3 +1,16 @@ +######################### +# Configuration options # +######################### + +# Repositories to highlight as a comma-delimited list. +# Example: aragon/aragon,aragon/aragon-apps,aragon/aragon-ui +TRACKED_REPOS= + + +######################## +# Development settings # +######################## + # Personal Github token, to avoid API throttling or to access private repos. # Create a token with the `repo` scope at https://github.com/settings/tokens. # diff --git a/README.md b/README.md index 24708d6..98f05cc 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ Dashboard for keeping track of Github pull requests across repos, users, and org ## Configuration +Tracked repos (and the user / organization headings) are configured via an environment variable. + +- `TRACKED_REPOS`: A comma-delimited list of repositories to track and automatically fetch pull requests from. Example configuration: `'aragon/aragon,aragon/aragon-apps,aragon/aragon-ui'` + + +More documentation is available in [`env.sample`](./env.sample). + ### Development - `GITHUB_TOKEN`: Personal Github token ([create one with the `repo` scope](https://github.com/settings/tokens), to decrease API throttling and allow access of private repos during development. **NOT** meant for production usage. diff --git a/now.json b/now.json index b2762d4..8d568ce 100644 --- a/now.json +++ b/now.json @@ -4,5 +4,10 @@ "scope": "aragonone", "github": { "silent": true + }, + "build": { + "env": { + "TRACKED_REPOS": "aragon/aragon, aragon/aragon-apps, aragon/aragon-ui, aragon/aragon.js, aragon/aragonOS, aragon/aragon-cli, aragon/aragon-court, aragon/buidler-plugin, aragon/court-dashboard, aragon/radspec, aragon/use-wallet, aragonone/court-backend, aragonone/notification-service" + } } } diff --git a/rollup.config.js b/rollup.config.js index 95d72b6..1bf520d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -22,6 +22,7 @@ module.exports = { replace({ 'process.env.NODE_ENV': JSON.stringify('production'), 'process.env.GITHUB_TOKEN': JSON.stringify(process.env.GITHUB_TOKEN), + 'process.env.TRACKED_REPOS': JSON.stringify(process.env.TRACKED_REPOS), }), ], } diff --git a/src/index.js b/src/index.js index 024dc35..805ebbb 100644 --- a/src/index.js +++ b/src/index.js @@ -16,14 +16,7 @@ const GITHUB_API_HEADERS = { authorization: GITHUB_TOKEN ? `token ${GITHUB_TOKEN}` : null } -const REPOS = [ - 'aragon/aragon', - 'aragon/aragon-apps', - 'aragon/aragon-ui', - 'aragon/aragon.js', - 'aragon/aragonOS', - 'aragon/aragon-cli', -] +const REPOS = process.env.TRACKED_REPOS.split(',').map(repo => repo.trim()) const GROUPS = [ [30, '😭'],