Skip to content

Instantly share code, notes, and snippets.

@albingroen
Last active June 4, 2021 15:22
Show Gist options
  • Save albingroen/ff8866aa4b56ac9c00ca9eb6bb7d916b to your computer and use it in GitHub Desktop.
Save albingroen/ff8866aa4b56ac9c00ca9eb6bb7d916b to your computer and use it in GitHub Desktop.
Delete multiple GitHub repos from your profile
#!/usr/bin/env node
const axios = require("axios");
// ADD THE NAME OF THE REPOS YOU WANT TO DELETE HERE
const repos = [];
// ADD YOUR GITHUB USERNAME HERE
const username = ""
// ADD YOUR GITHUB ACCESS TOKEN HERE
const token = ""
const main = () => {
repos.forEach((name) => {
try {
axios
.delete(`https://api.github.com/repos/${username}/${name}`, {
headers: {
Authorization: `bearer ${token}`,
},
})
.then(() => {
console.log(`Successfully deleted ${name}`);
})
.catch((err) => {
console.log(`Failed to delete ${name}`);
console.log(err.message)
});
} catch (err) {
console.log("Something went wrong");
throw Error(err);
}
});
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment