Skip to content

Commit 0a9e2e0

Browse files
committed
Revert "SP-2020 remove releaseDate and customfield_11108 usage"
This reverts commit b8ce4ec.
1 parent 2912fa8 commit 0a9e2e0

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ A GitHub action that uses a tag name and a list of Issue-IDs and updates their r
3434
- `issueIds` (required) - Comma separated list of Jira issues to update. Example: RE-1486,RE-1489
3535
- `componentName` (required) - The name of the component (service) to add as label to the issues
3636
- `tagName` (required) - The (git) release tag to add as label to the issues
37+
- `releaseDate` (optional) - The date to use as release date, default is 'now'
3738
- `notifyUsers` (optional) - Whether to notify user watching the Jira issues, default is 'false'
3839

3940
## Contributing

__tests__/jira.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ xtest('foo', async () => {
77
const result = await jira.updateIssues({
88
issueIds: ['RE-1486', 'RE-1489'],
99
componentName: 'foo-service',
10-
tagName: '2020.8.4'
10+
tagName: '2020.8.4',
11+
releaseDate: new Date(),
1112
})
1213

1314
expect(result).toEqual([])

action.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const arn = new Arn({webhookUrl});
1515
// 1. update JIRA issues
1616
// 2. send a webhook to the ARN (Automated release notes) - JIRA app -
1717
// with the componentName-tagName label
18-
async function exec ({ issueIds, componentName, tagName }) {
18+
async function exec ({ issueIds, componentName, tagName, releaseDate }) {
1919
try {
20-
console.log({ issueIds, componentName, tagName });
20+
console.log({ issueIds, componentName, tagName, releaseDate });
2121

2222
if (issueIds.length === 0) {
2323
console.log('No Jira issues given, do nothing');
@@ -29,6 +29,7 @@ async function exec ({ issueIds, componentName, tagName }) {
2929
issueIds,
3030
componentName,
3131
tagName,
32+
releaseDate,
3233
});
3334

3435
if (errors.length === 0) {
@@ -50,6 +51,7 @@ function parseArgs() {
5051
issueIds: filterIssueIds(core.getInput('issueIds')),
5152
componentName: core.getInput('componentName'),
5253
tagName: core.getInput('tagName') || process.env.TAGNAME,
54+
releaseDate: core.getInput('releaseDate') ? new Date(core.getInput('releaseDate')) : new Date(),
5355
notifyUsers: core.getInput('notifyUsers') === 'true',
5456
}
5557
}

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ inputs:
1313
tagName:
1414
description: "The (git) release tag to add as label to the issues"
1515
required: true
16+
releaseDate:
17+
description: "The date to use as release date, default is 'now'"
18+
required: false
1619
notifyUsers:
1720
description: "Whether to notify user watching the Jira issues, default is 'false'"
1821
required: false

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jira.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ class Jira {
3535
return issue;
3636
}
3737

38-
async updateIssues ({ issueIds, tagName, componentName, notifyUsers = false }) {
38+
async updateIssues ({ issueIds, releaseDate, tagName, componentName, notifyUsers = false }) {
3939
const calls = issueIds.map(async (issueId) => {
4040
try {
4141
const issue = await this.getIssueOrSubtaskParentIssue(issueId);
4242

43-
await this.updateIssue({ issue, tagName, componentName, notifyUsers });
43+
if (issue.fields.customfield_11108) {
44+
const oldReleaseDate = new Date(issue.fields.customfield_11108);
45+
46+
if (oldReleaseDate > releaseDate) {
47+
releaseDate = oldReleaseDate
48+
}
49+
}
50+
51+
await this.updateIssue({ issue, releaseDate, tagName, componentName, notifyUsers });
4452

4553
return null
4654
} catch (ex) {
@@ -55,7 +63,7 @@ class Jira {
5563

5664
// PUT /rest/api/3/issue/{issueIdOrKey}
5765
// see: https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-issue-issueIdOrKey-put
58-
async updateIssue ({ issue, tagName, componentName, notifyUsers }) {
66+
async updateIssue ({ issue, releaseDate, tagName, componentName, notifyUsers }) {
5967
const issueId = issue.key;
6068
//console.log('Updating ' + issueId);
6169
const response = await fetch(`${this.baseUrl}/rest/api/3/issue/${issueId}?notifyUsers=${notifyUsers}`, {
@@ -75,6 +83,9 @@ class Jira {
7583
},
7684
],
7785
},
86+
fields: {
87+
customfield_11108: releaseDate.toISOString(),
88+
},
7889
}),
7990
});
8091

0 commit comments

Comments
 (0)