add handler for milestones

This commit is contained in:
Andrea Maria Piana 2020-12-29 09:46:01 +01:00
parent 3c8fc9fb58
commit b609b96c8f
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
3 changed files with 56 additions and 18 deletions

View File

@ -1,6 +1,37 @@
const zh = require('../zh-client'), const zh = require('../zh-client'),
resolveIssueNumbers = require('../resolve-issue-number'), resolveIssueNumbers = require('../resolve-issue-number'),
{ INPUT_INPROG_COLUMN } = process.env; { INPUT_REVIEW_COLUMN, INPUT_INPROG_COLUMN, INPUT_NEXT_COLUMN } = process.env;
exports.milestoned = async function handleMilestonedIssue (tools) {
tools.log.info('Handling assigned issue...');
const failures = [],
{ payload } = tools.context;
const issueNo = payload.issue.number;
let zenHubIssue = await zh.issues.getIssue(payload.repository.id, issueNo);
if (!zenHubIssue) {
tools.log.info("issue not found")
return
}
if (zenHubIssue.pipeline.pipeline_id == INPUT_INPROG_COLUMN || zenHubIssue.pipeline.pipeline_id == INPUT_REVIEW_COLUMN) {
tools.log.info("issue already in progress or in review")
return
}
// Move it to the NEXT column
try {
tools.log.info(`Moving issue #${issueNo} to in progress...`);
await zh.issues.moveIssueBetweenPipelines(payload.repository.id, issueNo, {
pipeline_id: NEXT_INPROG_COLUMN,
position: 'top'
});
tools.log.info(`Moved #${issueNo} to in progress.`);
} catch (e) {
failures.push(`Failed to move #${issueNo} to in progress: ${e}`);
}
}
exports.assigned = async function handleAssignedIssue (tools) { exports.assigned = async function handleAssignedIssue (tools) {
tools.log.info('Handling assigned issue...'); tools.log.info('Handling assigned issue...');

6
package-lock.json generated
View File

@ -1281,6 +1281,12 @@
"load-json-file": "^4.0.0" "load-json-file": "^4.0.0"
} }
}, },
"prettier": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true
},
"psl": { "psl": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz",

View File

@ -13,6 +13,7 @@
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.2.0", "chai": "^4.2.0",
"mocha": "^8.2.0" "mocha": "^8.2.0",
"prettier": "2.2.1"
} }
} }