Created
November 7, 2023 22:10
-
-
Save shinshin86/dfe25ea9721f2386b97e34106ce95840 to your computer and use it in GitHub Desktop.
Script that runs in Deno to reconfigure to ignore notifications for Starred GitHub projects.
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
import { Octokit } from "https://esm.sh/octokit?dts"; | |
const personalAccessToken = "YOUR_PERSONAL_ACCESS_TOKEN"; | |
const octokit = new Octokit({ auth: personalAccessToken }); | |
async function getStarredRepos() { | |
try { | |
const response = await octokit.paginate("GET /user/starred"); | |
return response.map((repo) => ({ | |
owner: repo.owner.login, | |
repo: repo.name, | |
})); | |
} catch (error) { | |
console.error("Error fetching starred repositories: ", error); | |
return []; | |
} | |
} | |
async function updateWatchStatusForRepo(owner: string, repo: string) { | |
try { | |
await octokit.request("PUT /repos/{owner}/{repo}/subscription", { | |
owner, | |
repo, | |
subscribed: false, | |
ignored: true, | |
}); | |
console.log(`Updated watch status for ${owner}/${repo}`); | |
} catch (error) { | |
console.error(`Error updating watch status for ${owner}/${repo}: `, error); | |
} | |
} | |
async function main() { | |
const starredRepos = await getStarredRepos(); | |
for (const { owner, repo } of starredRepos) { | |
await updateWatchStatusForRepo(owner, repo); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment