Skip to content

GitHub org #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +31,7 @@ Just run the following commands:
export CIRCLE_CI_TOKEN=<your-token>
export GITHUB_USER=<your-user-name>
export GITHUB_TOKEN=<your-token>
export GITHUB_ORG=<github-organization>
docker-compose up -d
```

Expand All @@ -40,6 +42,7 @@ docker-compose up -d
1. `export CIRCLE_CI_TOKEN=<your-token>` (see above)
1. `export GITHUB_USER=<your-user-name>` (see above)
1. `export GITHUB_TOKEN=<your-token>` (see above)
1. `export GITHUB_ORG=<github-org>` (see above)
1. `npm start`
1. navigate to http://localhost:3000

Expand Down
15 changes: 13 additions & 2 deletions src/jobs/recent-circle-ci-builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down