-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[contributors-action] wip: action gerando json
- Loading branch information
Showing
6 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: 'Contributors JSON' | ||
description: 'Generates JSON with contributors per repository' | ||
outputs: | ||
contributors-json: | ||
description: 'The JSON with contributors' | ||
runs: | ||
using: 'node20' | ||
main: 'index.js' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"queremossabertheme":["Seb Bacon","Louise Crow","Mark Longair","Vitor Baptista","Matthew Landauer","Jody McIntyre","Robin Houston"],"queremossaber":["Seb Bacon","Louise Crow","Robin Houston","Matthew Landauer","Henare Degan","Faton Selishta","Mark Longair","M Somerville","Vitor Baptista","Brendan Molloy","Gaba E.","James Southern","Jedidiah","Paulo Geyer","Rowan Crawford","Tony Bowden"],"esic":["Vitor Baptista"],"queremossaber-docker":["Vitor Baptista"],"queremossaber.org.br":["Vitor Baptista"],"serenata-de-amor":["Eduardo Cuducos","Irio Musskopf","pyup.io bot","Jessica Temporal","Ana Schwendler","Giovani Sousa","Marcus Rehm","Mário Sérgio","Ana Paula Gomes","Fabio","Rogério Chaves","● filipe","Fábio Corrêa Cordeiro","Renan Alves Fonseca","Marcelo Lacerda","Felipe de Morais","Wisner Oliveira","Matheus Victor","Felipe Benites Cabral","Caio Carrara","Daniel Sakuma","Luiz Carlos Cavalcanti","André Pinho","Lui Pillmann","Oleg Utkin","Ricardo Baltazar Chaves","Vinicius Artur","Antonio Jr. Mattos","Leticia Portella"],"serenata-website":["Ana Schwendler","Eduardo Cuducos","Irio Musskopf","Mário Sérgio","Felipe Benites Cabral","Bruno Pazzim","Jessica Temporal","Ariane Camilo","● filipe","Everton Lima","Dalton Martins","Eduardo Henrique da Silva Freitas","Ellison","Lucas Dutra","Marco Cedaro","Raimundo Norberto","Rodrigo Prado","Victor Rosell","Vinícius Figueiredo","Youssef Muhamad "],"serenata-toolbox":["Eduardo Cuducos","Jessica Temporal","Ana Schwendler","Irio Musskopf","Felipe de Morais","Fabio","Giovani Sousa","Luiz Carlos Cavalcanti","יוֹנָתָן","Vinicius Artur","Humberto Rocha","willian.eth","Felipe Benites Cabral","Renne Rocha","Vitor Kusiaki","Mário Sérgio","Fábio C. Barrionuevo da Luz","Tulio Casagrande","Arioston","Yasser Rachid","Alexandre Augusto","Subbu Dantu","Tarsis Azevedo","Thadeu Luz","Vinicius Mesel","Vítor Bernardes","Marius-Constantin Melemciuc","Álvaro Justen"],"pedidosanonimos":["Vitor Baptista","Leo Tartari","Ítalo Epifânio","Rodolfo Lottin Pereira","Vinicius Artur"],"querido-diario":["José Guilherme Vanz","Renne Rocha","Irio Musskopf","Giulio Carvalho","Juliana Trevine","Eduardo Cuducos","Giovani Sousa","Mário Sérgio","Bruno Lellis","Danilo Jeremias da Silva","Rodrigo Vieira","Ana Paula Gomes","Rodolfo Lottin Pereira","Victor Torres","Alan R. Fachini","Alexandre Yukio Harano","Alvaro Mariano","Vitor Baptista","pedrogarcias","Gustavo Adolpho Bonesso","Felipe Ruhland","Helder Geovane Gomes de Lima","Daniel Farina","Jonathan Schweder","Fábio C. Barrionuevo da Luz","Luiz Eduardo","Camila Fracaro","Adorilson Bezerra"],"perfil-politico":["Eduardo Cuducos","Leticia Portella","pyup.io bot","Giulio Carvalho","Ariel Bello","Irio Musskopf","Álvaro Justen","Mário Sérgio","Adorilson Bezerra","Amadeu Cavalcante Filho","Debs Atanes"],"perfil-politico-frontend":["Carol X","Eduardo Cuducos","Giulio Carvalho","Guilherme Varandas","Vanessa Nascimento","Caio Gomes","Brenda Moreira","Elan van Biljon","Jakob Sjælland","Mário Sérgio","Victor Miranda"],"serenata-notebooks":["Eduardo Cuducos","Irio Musskopf","Jessica Temporal","Ana Schwendler","Marcus Rehm","Fabio","Thiago Almeida","● filipe","Ana Paula Gomes","Fábio Corrêa Cordeiro","Renan Alves Fonseca","Marcelo Lacerda","pyup.io bot","Wisner Oliveira","Daniel Sakuma","André Pinho","Lui Pillmann","Felipe Benites Cabral","Leticia Portella","Luiz Carlos Cavalcanti","Caio Pereira Oliveira","Matheus Cunha","Tales Paiva Nogueira","Richard","Samuel Grigolato","Vitor Kusiaki"," Júlia Carmona","Alessandro Parma","Bruno Pazzim"],"embaixadoras":["Mário Sérgio","Ariane Camilo","Juliana Trevine","RasRbk","Rafael Martinati","Claudia Regina","Lucas Prado","Giulio Carvalho","Fernanda","Guilherme Augusto","Vinicius Batista de Oliveira","Augusto Herrmann","Tiago José","Daniel Ferreira Silva","José Guilherme Vanz","Enderson Menezes (Mr. Enderson)","Douglas Antonio","Ana Paula Gomes","André Lopes","Arthur Oliveira ","Felipe Carvalho","Gabriel Dos Santos","Ivan Lemos","Juliany Raiol","Karel","Ramon Domingos","Robson Junqueira da Rosa","Rosangela Lotfi"],"querido-diario-infra":["José Guilherme Vanz","Giulio Carvalho"],"site":["Mário Sérgio","Giulio Carvalho","Peter","Thailo Eduardo"],"querido-diario-api":["José Guilherme Vanz","Giulio Carvalho","André Formento","Pedro Guimarães","Juliana Trevine","Eduardo Cuducos","Fernanda","Gerardo Alcantara","Jonathan Schweder"],"censo-querido-diario":["Mário Sérgio","Ariane Camilo","Juliana Trevine","Giulio Carvalho","Bernardo Chrispim Baron","David Alves","Geovane Oliveira de Carvalho","Ana Cecília Vieira","Fausto Sá Teles","Vini Antonini","Ana Paula Gomes","Augusto Herrmann"],"perfil-politico-notebooks":["Mário Sérgio"],"querido-diario-data-processing":["Giulio Carvalho","José Guilherme Vanz","André Formento"],"querido-diario-toolbox":["José Guilherme Vanz","Andre Assumpcao","Giulio Carvalho","Fernanda","Mário Sérgio","Juliana Trevine"],"querido-diario-comunidade":["Juliana Trevine","Giulio Carvalho","Renne Rocha","Mário Sérgio","Ellen Costa-Almeida","Isabella Ramos","José Guilherme Vanz","Lucas Guima","Morgana","Ricardo Ogando","Ítalo Epifânio"],"querido-diario-api-wrapper":["Renne Rocha","Juliana Trevine","Rafael Carreiro","Rafael Estevam"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const core = require('@actions/core'); | ||
const { HttpClient } = require('@actions/http-client'); | ||
|
||
const { URLSearchParams } = require('url'); | ||
|
||
const doGet = async (url) => { | ||
let headers = {} | ||
if (process.env.PRIVATE_TOKEN) { | ||
headers = { | ||
authorization: `Bearer ${process.env.PRIVATE_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}`); | ||
return await doGet(`https://api.github.com/orgs/${org}/repos?${new URLSearchParams(query)}`); | ||
} | ||
|
||
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 = (payload) => { | ||
core.setOutput("contributors-json", payload) | ||
} | ||
|
||
(async () => { | ||
const owner = 'okfn-brasil'; | ||
|
||
const repoNames = (await listOrgRepos(owner, { per_page: 100, type: 'public' })) | ||
.filter(repo => !(repo.archived || repo.disabled)) | ||
.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)); | ||
|
||
})() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"@actions/core": "^1.10.1", | ||
"@actions/http-client": "^2.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "contributors-action" | ||
|
||
jobs: | ||
contributors-json: | ||
runs-on: ubuntu-latest | ||
name: Gera contributors.json | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.2.0 | ||
- run: yarn add @actions/core @actions/http-client | ||
- uses: ./.github/actions/contributors-json | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: contributors-json | ||
path: contributors.json |