Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shinshin86/dfe25ea9721f2386b97e34106ce95840 to your computer and use it in GitHub Desktop.
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.
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