-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c8daaa
commit 68ec42b
Showing
841 changed files
with
156,637 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = __importStar(require("@actions/core")); | ||
const github_1 = require("@actions/github"); | ||
const Octokit_1 = __importDefault(require("./integrations/Octokit")); | ||
const dateUtils_1 = require("./utils/dateUtils"); | ||
const constants_1 = require("./constants"); | ||
exports.run = () => __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const githubToken = core.getInput('GH_TOKEN'); | ||
const ok = new Octokit_1.default(githubToken); | ||
const issues = yield ok.listAllOpenIssues(github_1.context.repo.owner, github_1.context.repo.repo); | ||
const results = yield ok.getIssuesWithDueDate(issues); | ||
results.forEach((issue) => __awaiter(this, void 0, void 0, function* () { | ||
const daysUtilDueDate = yield dateUtils_1.datesToDue(issue.due); | ||
if (daysUtilDueDate <= 7 && daysUtilDueDate > 0) { | ||
yield ok.addLabelToIssue(github_1.context.repo.owner, github_1.context.repo.repo, issue.number, [constants_1.NEXT_WEEK_TAG_NAME]); | ||
} | ||
else if (daysUtilDueDate <= 0) { | ||
yield ok.removeLabelFromIssue(github_1.context.repo.owner, github_1.context.repo.repo, constants_1.NEXT_WEEK_TAG_NAME, issue.number); | ||
yield ok.addLabelToIssue(github_1.context.repo.owner, github_1.context.repo.repo, issue.number, [constants_1.OVERDUE_TAG_NAME]); | ||
} | ||
})); | ||
return { | ||
ok: true, | ||
issuesProcessed: results.length, | ||
}; | ||
} | ||
catch (e) { | ||
core.setFailed(e.message); | ||
throw e; | ||
} | ||
}); | ||
exports.run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OVERDUE_TAG_NAME = 'Overdue'; | ||
exports.NEXT_WEEK_TAG_NAME = 'Due in next week'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const github_1 = require("@actions/github"); | ||
const front_matter_1 = __importDefault(require("front-matter")); | ||
class Octokit { | ||
constructor(token) { | ||
this.client = new github_1.GitHub(token); | ||
} | ||
listAllOpenIssues(owner, repo) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { data } = yield this.client.issues.listForRepo({ | ||
owner, | ||
repo, | ||
state: 'open', | ||
}); | ||
return data; | ||
}); | ||
} | ||
get(owner, repo, issueNumber) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { data } = yield this.client.issues.get({ | ||
owner, | ||
repo, | ||
issue_number: issueNumber, | ||
}); | ||
return data; | ||
}); | ||
} | ||
addLabelToIssue(owner, repo, issueNumber, labels) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { data } = yield this.client.issues.addLabels({ | ||
owner, | ||
repo, | ||
issue_number: issueNumber, | ||
labels, | ||
}); | ||
return data; | ||
}); | ||
} | ||
removeLabelFromIssue(owner, repo, name, issue_number) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const { data } = yield this.client.issues.removeLabel({ | ||
owner, | ||
repo, | ||
name, | ||
issue_number, | ||
}); | ||
return data; | ||
} | ||
catch (e) { | ||
// Do not throw error | ||
return []; | ||
} | ||
}); | ||
} | ||
getIssuesWithDueDate(rawIssues) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rawIssues.filter(issue => { | ||
// TODO: Move into utils | ||
const meta = front_matter_1.default(issue.body); | ||
if (meta.attributes && meta.attributes.due) { | ||
return Object.assign(issue, { due: meta.attributes.due }); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
exports.default = Octokit; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const moment_1 = __importDefault(require("moment")); | ||
exports.datesToDue = (date) => { | ||
const eventDate = moment_1.default(date); | ||
const today = moment_1.default(); | ||
return eventDate.diff(today, 'days'); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.