Created
January 29, 2023 16:57
-
-
Save guibranco/ae03222275a64ed522e3166444f5ae1e to your computer and use it in GitHub Desktop.
Create an issue on each user/org repository that is not a fork and has issues enabled
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
//Request the user/org repositories, and add this script to tests tab of the request | |
//Repositories of a specific user: https://api.github.com/users/{{username}}/repos | |
//Repositories of a specific org: https://api.github.com/orgs/{{org}}/repos | |
const ghToken = pm.globals.get("GH_PAT"); | |
const authorizationHeader = `Authorization: Bearer ${ghToken}`; | |
const issueTitle = "Issue title"; | |
const issueBody = "Issue body"; | |
const repositories = pm.response.json(); | |
for (let i = 0; i < repositories.length; i++) { | |
const repository = repositories[i]; | |
if (!repository.has_issues || repository.fork) { | |
continue; | |
} | |
const createIssue = `https://api.github.com/repos/${repository.full_name}/issues`; | |
pm.sendRequest( | |
{ | |
url: createIssue, | |
method: "POST", | |
header: authorizationHeader, | |
body: JSON.stringify({ | |
title: issueTitle, | |
body: issueBody | |
}), | |
}, | |
function (err, res) { | |
console.log(res); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment