Skip to content

Commit 25176f0

Browse files
authoredOct 21, 2020
Merge pull request #21 from atlassian/bugfix/set-neutral-fix
Action update to latest actions API
2 parents e04b2df + 01165dc commit 25176f0

File tree

6 files changed

+54
-15
lines changed

6 files changed

+54
-15
lines changed
 

‎.github/workflows/find-issue-key.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@ jobs:
1919
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
2020

2121
- name: Find Issue Key
22-
id: find
2322
uses: ./
2423
with:
2524
from: commits
2625

26+
- name: Find Issue Key
27+
id: find
28+
uses: ./
29+
with:
30+
string: Search is performed in this string. GA-250 will be found
31+
32+
- name: Find Issue Key
33+
uses: ./
34+
with:
35+
string: ${{ github.event.ref }} will search in branch name
36+
2737
- name: Find issue info
2838
run: echo "Issue ${{ steps.find.outputs.issue }} was found"

‎README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ For examples on how to use this, check out the [gajira-demo](https://github.com/
88

99
> ##### Note: this action requires [Jira Login Action](https://github.com/marketplace/actions/jira-login)
1010
11+
To find an issue key inside github event (branch):
12+
```yaml
13+
- name: Find in commit messages
14+
uses: atlassian/gajira-find-issue-key@master
15+
with:
16+
string: ${{ github.event.ref }}
17+
```
18+
19+
Or do the same using shortcut `from`:
20+
```yaml
21+
- name: Find in commit messages
22+
uses: atlassian/gajira-find-issue-key@master
23+
with:
24+
from: branch
25+
```
26+
1127
To find an issue key inside commit messages:
1228
```yaml
1329
- name: Find in commit messages
@@ -23,9 +39,8 @@ To find an issue key inside commit messages:
2339
- None
2440

2541
### Inputs
26-
- `description` - Provide jsonpath for the GitHub event to extract issue from
2742
- `string` - Provide a string to extract issue key from
28-
- `from` - Find from predefined place (should be either 'branch', or 'commits', default is 'commits')
43+
- `from` - Find from predefined place (should be either 'branch', or 'commits')
2944

3045
### Outputs
3146
- `issue` - Key of the found issue

‎action.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,31 @@ module.exports = class {
2222
}
2323

2424
async execute () {
25-
const template = eventTemplates[this.argv.from] || this.argv._.join(' ')
26-
const extractString = this.preprocessString(template)
27-
const match = extractString.match(issueIdRegEx)
25+
if (this.argv.string) {
26+
const foundIssue = await this.findIssueKeyIn(this.argv.string)
27+
28+
if (foundIssue) return foundIssue
29+
}
30+
31+
if (this.argv.from) {
32+
const template = eventTemplates[this.argv.from]
33+
34+
if (template) {
35+
const searchStr = this.preprocessString(template)
36+
const foundIssue = await this.findIssueKeyIn(searchStr)
37+
38+
if (foundIssue) return foundIssue
39+
}
40+
}
41+
}
42+
43+
async findIssueKeyIn (searchStr) {
44+
const match = searchStr.match(issueIdRegEx)
45+
46+
console.log(`Searching in string: \n ${searchStr}`)
2847

2948
if (!match) {
30-
console.log(`String "${extractString}" does not contain issueKeys`)
49+
console.log(`String does not contain issueKeys`)
3150

3251
return
3352
}

‎action.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ branding:
44
icon: 'book-open'
55
color: 'blue'
66
inputs:
7-
event:
8-
description: Provide jsonpath for the GitHub event to extract issue from
9-
required: false
107
string:
118
description: Provide a string to extract issue key from
129
required: false
1310
from:
14-
description: Find from predefined place (should be either 'branch', or 'commits', default is 'commits')
11+
description: Find from predefined place (should be either 'branch', or 'commits')
1512
required: false
1613
default: commits
1714
outputs:

‎dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ async function exec () {
3434
return fs.appendFileSync(cliConfigPath, yamledResult)
3535
}
3636

37-
console.log('No issueKeys found.')
38-
core.setNeutral()
37+
console.log('No issue keys found.')
3938
} catch (error) {
4039
core.setFailed(error.toString())
4140
}
4241
}
4342

4443
function parseArgs () {
4544
return {
46-
event: core.getInput('event') || config.event,
4745
string: core.getInput('string') || config.string,
4846
from: core.getInput('from'),
4947
}

0 commit comments

Comments
 (0)
Failed to load comments.