-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,4 @@ typings/ | |
dist/ | ||
|
||
.idea/ | ||
release.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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; | ||
}); | ||
} | ||
addLabelToIssue(owner, repo, issueNumber, labels) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.client.issues.addLabels({ | ||
owner, | ||
repo, | ||
issue_number: issueNumber, | ||
labels, | ||
}); | ||
}); | ||
} | ||
removeLabelFromIssue(owner, repo, name, issue_number) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.client.issues.removeLabel({ | ||
owner, | ||
repo, | ||
name, | ||
issue_number, | ||
}); | ||
}); | ||
} | ||
getIssuesWithDueDate(rawIssues) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return rawIssues.filter(issue => { | ||
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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("./Octokit")); | ||
const dateUtils_1 = require("./utils/dateUtils"); | ||
const run = () => __awaiter(void 0, 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(void 0, 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, ['Due in next week']); | ||
} | ||
else if (daysUtilDueDate <= 0) { | ||
yield ok.removeLabelFromIssue(github_1.context.repo.owner, github_1.context.repo.repo, 'Due in next week', issue.number); | ||
yield ok.addLabelToIssue(github_1.context.repo.owner, github_1.context.repo.repo, issue.number, ['Overdue']); | ||
} | ||
})); | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
}); | ||
run(); |
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.