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

GitHub Action para gerar lista de Contribuidores #184

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5f4e7b9
[contributors-action] initial commit
nkzren Oct 5, 2023
77b9e72
[contributors-action] test
nkzren Oct 5, 2023
b3f57b4
[contributors-action] test without upload
nkzren Oct 5, 2023
e358ba5
[contributors-action] altera trigger do workflow
nkzren Oct 5, 2023
8443175
traduz a lista de contribuidores e altera posição da badge
nkzren Oct 5, 2023
c60ddc7
atualiza lista de pessoas contribuidoras
nkzren Oct 5, 2023
b46671e
[contributors-action] altera gatilho da GH Action + ajustes no Docker…
nkzren Oct 6, 2023
d2b21b5
[contributors-action] atualiza docs
nkzren Oct 6, 2023
87dd0f4
[contributors-action] adiciona CONTRIBUTORS-en-US
nkzren Oct 6, 2023
bca38dc
[contributors-action] okfn-contributors -> contributors
nkzren Oct 9, 2023
e176cae
[contributors-action] altera contribuição padrão para code,doc
nkzren Oct 9, 2023
57038ac
[contributors-action] wip: action gerando json
nkzren Oct 10, 2023
cf8f548
[contributors-action] adiciona PRIVATE_TOKEN
nkzren Oct 10, 2023
d88c4b9
[contributors-action] teste
nkzren Oct 11, 2023
16cd0c0
[contributors-action] cleanup && change to input
nkzren Oct 11, 2023
0edf613
[contributors-action] altera secret
nkzren Oct 11, 2023
39eaa56
[contributors-action] altera o nome do token
nkzren Oct 11, 2023
b38a713
[contributors-action] fix http request
nkzren Oct 11, 2023
1221671
[contributors-action] output -> file
nkzren Oct 11, 2023
23be907
[contributors-action] fix writeFile
nkzren Oct 11, 2023
7cbb7e5
[contributors-action] remove filtro de repos
nkzren Oct 11, 2023
86345e1
[contributors-action] readiciona filtro
nkzren Oct 11, 2023
2f4b39a
[contributors-action] fix pagination
nkzren Oct 11, 2023
f4ab60d
[contributors-action] remove trigger do workflow
nkzren Oct 11, 2023
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
156 changes: 156 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"projectName": "querido-diario-frontend",
"projectOwner": "okfn-brasil",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"docs/README.md",
"docs/README-en-US.md",
"docs/CONTRIBUTORS.md",
"docs/CONTRIBUTORS-en-US.md",
"docs/CONTRIBUTING.md",
"docs/CONTRIBUTING-en-US.md"
],
"imageSize": 100,
"commit": false,
"commitConvention": "angular",
"contributors": [
{
"login": "vinicivs-monteiro",
"name": "Vinícius Monteiro",
"avatar_url": "https://avatars.githubusercontent.com/u/1107639?v=4",
"profile": "https://github.com/vinicivs-monteiro",
"contributions": [
"doc"
]
},
{
"login": "trevineju",
"name": "Juliana Trevine",
"avatar_url": "https://avatars.githubusercontent.com/u/44185775?v=4",
"profile": "https://github.com/trevineju",
"contributions": [
"doc"
]
},
{
"login": "lguima",
"name": "Lucas Guima",
"avatar_url": "https://avatars.githubusercontent.com/u/1562097?v=4",
"profile": "https://www.linkedin.com/in/lucasguima",
"contributions": [
"doc"
]
},
{
"login": "LucasMendoncaWF",
"name": "LucasMendoncaWF",
"avatar_url": "https://avatars.githubusercontent.com/u/43712801?v=4",
"profile": "https://github.com/LucasMendoncaWF",
"contributions": [
"doc"
]
},
{
"login": "ogecece",
"name": "Giulio Carvalho",
"avatar_url": "https://avatars.githubusercontent.com/u/26327506?v=4",
"profile": "https://github.com/ogecece",
"contributions": [
"doc"
]
},
{
"login": "ArianeCamilo",
"name": "Ariane Camilo",
"avatar_url": "https://avatars.githubusercontent.com/u/32268301?v=4",
"profile": "https://github.com/ArianeCamilo",
"contributions": [
"doc"
]
},
{
"login": "tigreped",
"name": "Pedro Guimarães",
"avatar_url": "https://avatars.githubusercontent.com/u/1479330?v=4",
"profile": "https://github.com/tigreped",
"contributions": [
"doc"
]
},
{
"login": "rasrbk",
"name": "RasRbk",
"avatar_url": "https://avatars.githubusercontent.com/u/92368456?v=4",
"profile": "https://ok.org.br/",
"contributions": [
"doc"
]
},
{
"login": "guicalmeida",
"name": "Guilherme Almeida",
"avatar_url": "https://avatars.githubusercontent.com/u/60672629?v=4",
"profile": "https://github.com/guicalmeida",
"contributions": [
"doc"
]
},
{
"login": "trolzen",
"name": "trolzen",
"avatar_url": "https://avatars.githubusercontent.com/u/731584?v=4",
"profile": "https://github.com/trolzen",
"contributions": [
"doc"
]
},
{
"login": "malungo",
"name": "malungo",
"avatar_url": "https://avatars.githubusercontent.com/u/28476?v=4",
"profile": "https://github.com/malungo",
"contributions": [
"doc"
]
},
{
"login": "lucalves",
"name": "Lucas Alves",
"avatar_url": "https://avatars.githubusercontent.com/u/17712401?v=4",
"profile": "https://lucalves.github.io/",
"contributions": [
"doc"
]
},
{
"login": "sergiomario",
"name": "Mário Sérgio",
"avatar_url": "https://avatars.githubusercontent.com/u/2698516?v=4",
"profile": "https://github.com/sergiomario",
"contributions": [
"doc"
]
},
{
"login": "RenatoSiqueira",
"name": "Renato Siqueira",
"avatar_url": "https://avatars.githubusercontent.com/u/30542215?v=4",
"profile": "https://www.linkedin.com/in/renatosiqueira/",
"contributions": [
"doc"
]
},
{
"login": "Winzen",
"name": "Luiz Eduardo",
"avatar_url": "https://avatars.githubusercontent.com/u/94500122?v=4",
"profile": "https://github.com/Winzen",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
"linkToUsage": true
}
10 changes: 10 additions & 0 deletions .github/actions/contributors-json/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'Contributors JSON'
description: 'Generates JSON with contributors per repository'
inputs:
TOKEN:
description: "GitHub token to authenticate requests"
required: true
runs:
using: 'node20'
main: 'index.js'

68 changes: 68 additions & 0 deletions .github/actions/contributors-json/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const core = require('@actions/core');
const { HttpClient } = require('@actions/http-client');
const fs = require("fs/promises");

const { URLSearchParams } = require('url');

const doGet = async (url) => {
const headers = {
Authorization: `Bearer ${core.getInput("TOKEN")}`
}
const client = new HttpClient('client', [], { headers })
return (await client.getJson(url)).result;
}

const getRepoContributors = async (owner, repo, query) => {
console.info(`Getting ${owner}/${repo} contributors`);
return await doGet(`https://api.github.com/repos/${owner}/${repo}/contributors?${query}`);
}

const listOrgRepos = async (org, query) => {
console.info(`Getting repos from ${org}`);
const result = [];
const paginate = async (page) => {
const next = await doGet(`https://api.github.com/orgs/${org}/repos?${new URLSearchParams({...query, page})}`);
result.push(...next);
if (next.length || page > 10) { // page > 10 as safeguard
await paginate(page + 1);
}
return result;
}

return await paginate(1);
}

const getUser = async (user, query) => {
console.info(`Getting user info for ${user}`);
return await doGet(`https://api.github.com/users/${user}?${new URLSearchParams(query)}`);
}

const generateOutput = async (payload) => {
await fs.writeFile("contributors.json", payload)
}

(async () => {
const owner = 'okfn-brasil';
const repoNames = (await listOrgRepos(owner, { per_page: 100, type: 'public' }))
.filter(repo => !repo.archived)
.filter(repo => repo.name.includes("querido-diario"))
.map(repo => repo.name);

const contribMap = {};
for (const repo of repoNames) {
contribMap[repo] = [];

const contributors = (await getRepoContributors(owner, repo))
.map(c => c.login)

for (const contributor of contributors) {
const user = await getUser(contributor)
if (user.name) {
contribMap[repo].push(user.name)
}
}
}

generateOutput(JSON.stringify(contribMap));

})()
10 changes: 10 additions & 0 deletions .github/actions/contributors/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM docker.io/node:20

WORKDIR /opt/contributors

COPY package.json yarn.lock ./
RUN yarn global add all-contributors-cli@6.26.1

COPY entrypoint.sh entrypoint.sh

ENTRYPOINT [ "/opt/contributors/entrypoint.sh" ]
9 changes: 9 additions & 0 deletions .github/actions/contributors/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

export PATH="$(yarn global bin):$PATH"

all-contributors check --config $GITHUB_WORKSPACE/.all-contributorsrc \
| sed -n '2p' \
| sed 's/, /\n/g' \
| xargs -I {} all-contributors add --config $GITHUB_WORKSPACE/.all-contributorsrc {} code,doc

11 changes: 11 additions & 0 deletions .github/actions/contributors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"scripts": {
"contributors:add": "all-contributors add",
"contributors:check": "all-contributors check",
"contributors:generate": "all-contributors generate"
},
"license": "MIT",
"devDependencies": {
"all-contributors-cli": "^6.26.1"
}
}
Loading