Skip to content

Commit

Permalink
feat: update fix version on merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Timmatt-Lee committed Jan 22, 2021
1 parent a459ae5 commit a9b8311
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async function main() {
const otherAssignedTransition = core.getInput('otherAssignedTransition');
const isAssignToReporter = core.getInput('isAssignToReporter').toLowerCase() === 'true';
const isOnlyAppendDesc = core.getInput('isOnlyAppendDesc').toLowerCase() === 'true';
const isAddFixVersionOnMerge = core.getInput('isAddFixVersionOnMerge').toLowerCase() === 'true';
const appendDescAfterRegex = core.getInput('appendDescAfterRegex');

const gitService = new Github({ github, githubToken });
Expand Down Expand Up @@ -71,6 +72,10 @@ async function main() {
core.info('webhook complete');

if (pr.merged) {
if (isAddFixVersionOnMerge) {
const versionId = await jira.getVersionIdByPrefix(version);
await jira.putFixVersion(key, versionId);
}
process.exit(0);
}

Expand Down
12 changes: 12 additions & 0 deletions services/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ class Jira {
return this.request(`/rest/api/3/issue/${key}/assignee`, 'put', { accountId });
}

async putFixVersion(key, versionId) {
return this.request(`/rest/api/3/issue/${key}`, 'put', {
fields: {
fixVersions: [
{
id: versionId,
},
],
},
});
}

async request(api, method = 'get', data = {}) {
return request({
url: `${this.host}${api}`,
Expand Down

0 comments on commit a9b8311

Please sign in to comment.