Skip to content

Commit

Permalink
Merge pull request #1 from project-moonstar/actions-2-enable
Browse files Browse the repository at this point in the history
Actions 2 enable
  • Loading branch information
drudzikatlassian authored Sep 5, 2019
2 parents 85433e3 + 4ece017 commit 87eb72b
Show file tree
Hide file tree
Showing 10 changed files with 291 additions and 184 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/find-issue-key.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push

name: Test Find Issue Key

jobs:
test-find-issue-key:
name: Find Issue Key
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Login
uses: atlassian/gajira-login@master
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Find Issue Key
id: find
uses: ./

- name: Find issue info
run: echo "Issue ${{ steps.find.outputs.issue }} was found"
88 changes: 88 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
20 changes: 0 additions & 20 deletions Dockerfile

This file was deleted.

45 changes: 13 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,27 @@ For examples on how to use this, check out the [gajira-demo](https://github.com/
> ##### Note: this action requires [Jira Login Action](https://github.com/marketplace/actions/jira-login)
To find an issue key inside commit messages:
```yaml
- name: Find in commit messages
uses: atlassian/gajira-find-issue-key@master
with:
from: commits
```
action "Find in commit messages" {
uses = "atlassian/gajira-find-issue-key@master"
needs = ["Login"]
args = "--from=commits"
}
```


Also you can use [lodash templates](https://lodash.com/docs/4.17.11#template) to retrieve fields from GitHub Event which triggered workflow, like: `{{event.ref}}` Here is an example:

```
action "Find in branch name" {
uses = "atlassian/gajira-find-issue-key@master"
needs = ["Login"]
args = "{{event.ref}}"
}
```
which is the same as `--from=branch`

Or more complex one:

```
action "Find in commit messages" {
uses = "atlassian/gajira-find-issue-key@master"
needs = ["Login"]
args = "{{event.commits.map(c=>c.message).join(' ')}}"
}
```
which is the same as `--from=commits`
----
## Action Spec:
### Environment variables
- None
### Arguments
- `--from=commits` - Detect issue key in commit messages from event
- `--from=branch` - Detect issue key in branch name
### Inputs
- `description` - Provide jsonpath for the GitHub event to extract issue from
- `string` - Provide a string to extract issue key from
- `from` - Find from predefined place (should be either 'branch', or 'commits', default is 'commits')

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

### Reads fields from config file at $HOME/jira/config.yml
- None

Expand Down
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Jira Find Issue Key
description: Find an issue inside event
inputs:
event:
description: Provide jsonpath for the GitHub event to extract issue from
required: false
string:
description: Provide a string to extract issue key from
required: false
from:
description: Find from predefined place (should be either 'branch', or 'commits', default is 'commits')
required: false
default: commits
outputs:
issue:
description: Key of the found issue
runs:
using: 'node12'
main: './dist/index.js'
1 change: 1 addition & 0 deletions dist/index.js

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions entrypoint.sh

This file was deleted.

40 changes: 11 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const YAML = require('yaml')
const yargs = require('yargs')
const core = require('@actions/core')

const cliConfigPath = `${process.env.HOME}/.jira.d/config.yml`
const configPath = `${process.env.HOME}/jira/config.yml`
Expand All @@ -23,6 +23,9 @@ async function exec () {
console.log(`Saving ${result.issue} to ${cliConfigPath}`)
console.log(`Saving ${result.issue} to ${configPath}`)

// Expose created issue's key as an output
core.setOutput('issue', result.issue)

const yamledResult = YAML.stringify(result)
const extendedConfig = Object.assign({}, config, result)

Expand All @@ -32,39 +35,18 @@ async function exec () {
}

console.log('No issueKeys found.')
process.exit(78)
core.setNeutral()
} catch (error) {
console.error(error)
process.exit(1)
core.setFailed(error.toString())
}
}

function parseArgs () {
yargs
.option('event', {
alias: 'e',
describe: 'Provide jsonpath for the GitHub event to extract issue from',
default: config.event,
type: 'string',
})
.option('string', {
alias: 's',
describe: 'Provide a string to extract issue key from',
default: config.string,
type: 'string',
})
.option('from', {
describe: 'Find from predefined place',
type: 'string',
choices: ['branch', 'commits'],
})

yargs
.parserConfiguration({
'parse-numbers': false,
})

return yargs.argv
return {
event: core.getInput('event') || config.event,
string: core.getInput('string') || config.string,
from: core.getInput('from'),
}
}

exec()
Loading

0 comments on commit 87eb72b

Please sign in to comment.