Skip to content

Commit

Permalink
Merge pull request #2 from atlassian/merge-old-repo
Browse files Browse the repository at this point in the history
Merge old repo
  • Loading branch information
rudzon authored Feb 25, 2019
2 parents f8f6d88 + b2b1d75 commit 4dbe4cd
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ action "Jira Transition" {
}

action "Jira Find" {
uses = "./actions/find"
uses = "./actions/find-issue-key"
needs = ["Jira Transition"]
args = "GA-2"
args = "GA-1"
}
50 changes: 42 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
# GitHub Actions for Jira
The GitHub Actions for [Jira](https://www.atlassian.com/software/jira) to create and edit Jira issues

The GitHub Actions for [Jira](https://www.atlassian.com/software/jira) to create and edit Jira issues.
In the [demo-gajira](https://github.com/atlassian/gajira-demo) repository you'll find examples of what you can do with these actions, in particular:

- Automatically transition an issue to done when a pull request whose name contains the issue key is merged
- Automatically create a new Jira issue when a GitHub issue is created
- Automatically add a comment to a Jira issue when a commit message contains the issue key
- Automatically create a Jira issue for each `// TODO:` in code

## Actions
- [`Login`](./actions/login) - Stores credentials from environment variables
- [`CLI`](./actions/cli) - Wrapped [go-jira](https://github.com/Netflix-Skunkworks/go-jira) CLI
- [`Create`](./actions/create) - Create new Jira issue
- [`Transition`](./actions/transition) - Transition an issue
- [`Find`](./actions/find) - Find an issue to operate
- [`Comment`](./actions/comment) - Add a comment to an issue
- [`TODO`](./actions/todo) - Create Jira issue for TODO comments

- [`Login`](./actions/login) - Log in to the Jira API
- [`CLI`](./actions/cli) - Wrapped [go-jira](https://github.com/Netflix-Skunkworks/go-jira) CLI for common Jira actions
- [`Find issue key`](./actions/find-issue-key) - Search for an issue key in commit message, branch name, etc. This issue key is then saved and used by the next actions in the same workflow
- [`Create`](./actions/create) - Create a new Jira issue
- [`Transition`](./actions/transition) - Transition a Jira issue
- [`Comment`](./actions/comment) - Add a comment to a Jira issue
- [`TODO`](./actions/todo) - Create a Jira issue for each TODO comment in committed code

Each action supports command line parameters (e.g. `--from=branch`) and lodash (e.g. `{{event.ref}}` which is its equivalent) as input.

## Usage
An example workflow to create a Jira issue for each `//TODO` in code:

```
workflow "Todo issue" {
on = "push"
resolves = ["Jira Login"]
}
action "Jira Login" {
uses = "atlassian/gajira/actions/login@master"
secrets = ["JIRA_BASE_URL", "JIRA_API_TOKEN", "JIRA_USER_EMAIL"]
}
action "Jira TODO" {
needs = "Jira Login"
uses = "atlassian/gajira/actions/todo@master"
secrets = ["GITHUB_TOKEN"]
args = "--project=GA --issuetype=Task"
}
```

More examples at [gajira-demo](https://github.com/atlassian/gajira-demo) repository
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Jira Find
# Jira Find Issue Key
Extract issue key from string

## Usage
Expand Down
4 changes: 2 additions & 2 deletions actions/find/action.js → actions/find-issue-key/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const Jira = require('./common/net/Jira')
const issueIdRegEx = /([a-zA-Z0-9]+-[0-9]+)/g

const eventTemplates = {
'branch': "{{event.ref}}",
'commits': "{{event.commits.map(c=>c.message).join(' ')}}",
branch: '{{event.ref}}',
commits: "{{event.commits.map(c=>c.message).join(' ')}}",
}

module.exports = class {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class Jira {
const { fields = [], expand = [] } = query

try {
return this.fetch('getIssue', {
const res = await this.fetch('getIssue', {
pathname: `/rest/api/2/issue/${issueId}`,
query: {
fields: fields.join(','),
expand: expand.join(','),
},
})

return res
} catch (error) {
if (get(error, 'res.status') === 404) {
return
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion actions/todo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Single-line comments in these formats:
## Action Spec:

### Environment variables
- GITHUB_TOKEN
- `GITHUB_TOKEN` - GitHub secret [token](https://developer.github.com/actions/creating-workflows/storing-secrets/#github-token-secret) is used to retrieve diffs

### Arguments

Expand Down

0 comments on commit 4dbe4cd

Please sign in to comment.