mirror of
https://github.com/status-im/zenhub-automations.git
synced 2025-02-20 14:18:28 +00:00
add handling of issues assigned
This commit is contained in:
parent
0fc7ccad52
commit
d32ed164e2
1
index.js
1
index.js
@ -5,6 +5,7 @@ const tools = new Toolkit();
|
|||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
create: 'create.js',
|
create: 'create.js',
|
||||||
|
issues: 'issues.js',
|
||||||
ready_for_review: 'create.js',
|
ready_for_review: 'create.js',
|
||||||
pull_request: 'pull_request.js'
|
pull_request: 'pull_request.js'
|
||||||
}
|
}
|
||||||
|
@ -2,36 +2,13 @@ const zh = require('../zh-client'),
|
|||||||
resolveIssueNumbers = require('../resolve-issue-number'),
|
resolveIssueNumbers = require('../resolve-issue-number'),
|
||||||
{ INPUT_INPROG_COLUMN } = process.env;
|
{ INPUT_INPROG_COLUMN } = process.env;
|
||||||
|
|
||||||
exports.branch = async function handleCreatedBranch (tools) {
|
exports.assigned = async function handleAssignedIssue (tools) {
|
||||||
tools.log.info('Handling created branch...');
|
tools.log.info('Handling assigned issue...');
|
||||||
|
|
||||||
const failures = [],
|
const failures = [],
|
||||||
{ payload } = tools.context;
|
{ payload } = tools.context;
|
||||||
|
|
||||||
let issueNumbers = resolveIssueNumbers(payload.ref);
|
console.log(payload)
|
||||||
|
|
||||||
if (!issueNumbers || issueNumbers.length < 1) {
|
|
||||||
return tools.exit.neutral('No issues detected to act upon.');
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < issueNumbers.length; i++) {
|
|
||||||
let issueNo = issueNumbers[i];
|
|
||||||
|
|
||||||
// Assign sender to issue(s)
|
|
||||||
try {
|
|
||||||
tools.log.info(`Adding assignees for #${issueNo}...`);
|
|
||||||
|
|
||||||
await tools.github.issues.addAssignees({
|
|
||||||
owner: payload.repository.owner.login,
|
|
||||||
repo: payload.repository.name,
|
|
||||||
issue_number: issueNo,
|
|
||||||
assignees: [ payload.sender.login ]
|
|
||||||
});
|
|
||||||
|
|
||||||
tools.log.info(`Added assignees for #${issueNo}.`);
|
|
||||||
} catch (e) {
|
|
||||||
failures.push(`Failed to added assignees for #${issueNo}: ${e}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move issue(s) to INPROG_COLUMN
|
// Move issue(s) to INPROG_COLUMN
|
||||||
if (INPUT_INPROG_COLUMN) {
|
if (INPUT_INPROG_COLUMN) {
|
||||||
@ -48,7 +25,6 @@ exports.branch = async function handleCreatedBranch (tools) {
|
|||||||
failures.push(`Failed to move #${issueNo} to in progress: ${e}`);
|
failures.push(`Failed to move #${issueNo} to in progress: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (failures.length) {
|
if (failures.length) {
|
||||||
throw new Error(`Failed to execute some actions: ${failures.map(x => x.message || x).join(', ')}`);
|
throw new Error(`Failed to execute some actions: ${failures.map(x => x.message || x).join(', ')}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user