Created
November 28, 2020 12:50
-
-
Save jasvazquez/1ed1c39e18aa1eb8bb4bd8a7d2d58055 to your computer and use it in GitHub Desktop.
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
// Parámetros del script | |
// --- | |
const ACCESS_TOKEN ="3kjfkj34fhdk3k35858fkfkfi"; | |
// Repositorio al que añadir colaboradores y su propietario (usuario de Github que lo ha creado) | |
const REPO='Documentacion'; | |
const OWNER='tuUsuarioGitHub'; | |
function registrarColaborador(idColaborador='') { | |
url = https://api.github.com/repos/${OWNER}/${REPO}/collaborators/${idColaborador} | |
var options = { | |
'method' : 'PUT', | |
"headers" : { | |
authorization: token ${ACCESS_TOKEN}, | |
} | |
}; | |
// Petición | |
// --- | |
try { | |
var response = UrlFetchApp.fetch(url,options); | |
} catch (error) { | |
Logger.log(`"${idColaborador}" no existe como usuario de GitHub`); | |
return; | |
} | |
Logger.log(`Invitado "${idColaborador}" como colaborador del proyecto "${REPO}/${OWNER}"`); | |
} | |
function prueba(){ | |
registrarColaborador('jasvazquez'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment