diff --git a/README.md b/README.md index fdc1e57..6431393 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ metricio: CIRCLE_CI_TOKEN: $CIRCLE_CI_TOKEN GITHUB_USER: $GITHUB_USER GITHUB_TOKEN: $GITHUB_TOKEN + GITHUB_ORG: $GITHUB_ORG redis: container_name: circle-ci-wall-redis @@ -30,6 +31,7 @@ Just run the following commands: export CIRCLE_CI_TOKEN= export GITHUB_USER= export GITHUB_TOKEN= +export GITHUB_ORG= docker-compose up -d ``` @@ -40,6 +42,7 @@ docker-compose up -d 1. `export CIRCLE_CI_TOKEN=` (see above) 1. `export GITHUB_USER=` (see above) 1. `export GITHUB_TOKEN=` (see above) +1. `export GITHUB_ORG=` (see above) 1. `npm start` 1. navigate to http://localhost:3000 diff --git a/src/jobs/recent-circle-ci-builds.js b/src/jobs/recent-circle-ci-builds.js index 33a9faf..5ea63d5 100644 --- a/src/jobs/recent-circle-ci-builds.js +++ b/src/jobs/recent-circle-ci-builds.js @@ -23,7 +23,7 @@ function getRecentBuilds(limit = 10) { } function getBuildDetails(build) { - const uri = `https://circleci.com/api/v1.1/project/github/ePages-de/${build.reponame}/${build.circleCiJob}`; + const uri = `https://circleci.com/api/v1.1/project/github/${build.owner}/${build.reponame}/${build.circleCiJob}`; return request({ ...requestOptions, @@ -124,6 +124,17 @@ export const perform = async () => { const key = (workflows || {}).workflow_id || (reponame + branch); + if (!branch) { + // if build does not contains branch (e.g. tag build) + return allBuilds + } + + const GITHUB_ORG = process.env['GITHUB_ORG'] + if (GITHUB_ORG && username !== GITHUB_ORG) { + return allBuilds; + } + + // skip all but the most recent builds for the same branch if (Object.values(allBuilds).find( b => b.reponame === reponame @@ -174,7 +185,7 @@ export const perform = async () => { if (build.buildStatus === 'failed') { if (build.workflowSteps && build.workflowSteps.length > 1) { for await (const step of build.workflowSteps) - step.failedStep = ((await getBuildDetails(step)) + step.failedStep = ((await getBuildDetails(build)) .steps.find(step => step.actions.find(action => action.failed)) || {}) .name;