-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteCards.js
More file actions
40 lines (37 loc) · 1.32 KB
/
Copy pathdeleteCards.js
File metadata and controls
40 lines (37 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Octokit = require('@octokit/rest');
const fs = require("fs");
const { apiKey } = require('./apikey');
const octokit = new Octokit({
auth: apiKey
});
const { students, repo, owner } = JSON.parse(fs.readFileSync("projectConfig.json"));
// deletes 1st page of project cards, re-run to delte all of them
students.forEach((student, index) => {
setTimeout(() => {
octokit.projects.listForRepo({
// owner of repo (could be an organization)
owner: owner,
// the repo's name
repo: `${repo}-${student}`
}).then(({ data, headers, status }) => {
let studentProj = data[0];
octokit.projects.listColumns({
project_id: studentProj.id
}).then(({ data, headers, status }) => {
let toDoColumn = data[0];
octokit.projects.listCards({
column_id: toDoColumn.id
}).then(({ data, headers, status }) => {
let cardArray = data;
cardArray.forEach(card => {
octokit.projects.deleteCard({
card_id: card.id
});
});
});
});
}).catch(error => {
console.log(error);
});
}, 4000 * index);
});