Skip to content
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

12 קבלת נתונים מגיבטהב #14

Merged
merged 7 commits into from
Aug 15, 2022
Merged
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "@patternfly/elements" }
2 changes: 2 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
run: npm ci

- name: Build site
env:
SITE_GITHUB_TOKEN: "${{ secrets.SITE_GITHUB_TOKEN }}"
run: npm run build

- name: Configure git
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
run: npm ci

- name: Build site
env:
SITE_GITHUB_TOKEN: "${{ secrets.SITE_GITHUB_TOKEN }}"
run: npm run build

- name: Configure git
Expand Down
73 changes: 73 additions & 0 deletions _data/contributors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* eslint-disable no-undef */
const { graphql } = require('@octokit/graphql');

const ORGANIZATION_NAME = 'RedHat-Israel'; // organization namespace
const MAX_CONTRIBUTORS = 100; // modify this if/when we have more then 100 members

/**
* Fetch Contributor data from GitHub and elsewhere
* @param {*} configData see https://www.11ty.dev/docs/data-js/#arguments-to-global-data-files
* @example
* ```html
* <ul>{% for contributor in contributors %}
* <li>{{ contributor.name }}</li>{% endfor %}
* </ul>
* ```
*/
async function israelContributors(configData) {
// REQUIRED: set token from a Secret into the SITE_GITHUB_TOKEN environment variable in the CI workflow
// token requirements: https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#authenticating-with-graphql
const requestParams = {
headers: {
authorization: `bearer ${process.env.SITE_GITHUB_TOKEN}`,
}
};

const query = `
{
organization (login: "${ORGANIZATION_NAME}") {
membersWithRole(first: ${MAX_CONTRIBUTORS}) {
nodes {
contributionsCollection {
hasAnyContributions
totalCommitContributions
totalIssueContributions
totalPullRequestContributions
totalPullRequestReviewContributions
totalRepositoryContributions
}
}
}
}
}
`;

const result = await graphql(query, requestParams);

const organizationContributionSummary = {
totalCommitContributions: 0,
totalIssueContributions: 0,
totalPullRequestContributions: 0,
totalPullRequestReviewContributions: 0,
totalRepositoryContributions: 0
};

result.organization.membersWithRole.nodes
.filter(node => node.contributionsCollection.hasAnyContributions)
.forEach(node => {
organizationContributionSummary.totalCommitContributions +=
node.contributionsCollection.totalCommitContributions;
organizationContributionSummary.totalIssueContributions +=
node.contributionsCollection.totalIssueContributions;
organizationContributionSummary.totalPullRequestContributions +=
node.contributionsCollection.totalPullRequestContributions;
organizationContributionSummary.totalPullRequestReviewContributions +=
node.contributionsCollection.totalPullRequestReviewContributions;
organizationContributionSummary.totalRepositoryContributions +=
node.contributionsCollection.totalRepositoryContributions;
});

// TODO: TBD fetched contributions data usage stored in organizationContributionSummary
}

module.exports = israelContributors;
Loading