Skip to content

Commit c2f792f

Browse files
authoredSep 6, 2019
Merge pull request #1 from project-moonstar/actions-2-enable
"Actions v2"-enable gajira-cli
2 parents d432a79 + fcfd61c commit c2f792f

13 files changed

+265
-57
lines changed
 

‎.dockerignore

-4
This file was deleted.

‎.github/workflows/setup.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
push
3+
4+
name: Test setup
5+
6+
jobs:
7+
test-setup:
8+
name: Setup
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@master
13+
14+
- name: Setup
15+
uses: ./
16+
with:
17+
version: 1.0.20
18+
19+
- name: Print version
20+
run: |
21+
jira version

‎.gitignore

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional REPL history
57+
.node_repl_history
58+
59+
# Output of 'npm pack'
60+
*.tgz
61+
62+
# Yarn Integrity file
63+
.yarn-integrity
64+
65+
# dotenv environment variables file
66+
.env
67+
.env.test
68+
69+
# parcel-bundler cache (https://parceljs.org/)
70+
.cache
71+
72+
# next.js build output
73+
.next
74+
75+
# nuxt.js build output
76+
.nuxt
77+
78+
# vuepress build output
79+
.vuepress/dist
80+
81+
# Serverless directories
82+
.serverless/
83+
84+
# FuseBox cache
85+
.fusebox/
86+
87+
# DynamoDB Local files
88+
.dynamodb/

‎Dockerfile

-19
This file was deleted.

‎README.md

+13-28
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
# Jira CLI
2-
Wrapped go-jira CLI action. Check out [go-jira documentation](https://github.com/Netflix-Skunkworks/go-jira) for more arguments and usage details
1+
# setup-jira
2+
Download and set up go-jira CLI. Check out [go-jira documentation](https://github.com/Netflix-Skunkworks/go-jira) for more arguments and usage details
33

44
For examples on how to use this, check out the [gajira-demo](https://github.com/atlassian/gajira-demo) repository
5+
56
> ##### Only supports Jira Cloud. Does not support Jira Server (hosted)
67
78
## Usage
89

9-
> ##### Note: this action requires [Jira Login Action](https://github.com/marketplace/actions/jira-login)
10-
11-
Example workflow to add a comment to an issue:
10+
#### Set up
1211
```
13-
workflow "Comment issue" {
14-
on = "push"
15-
resolves = ["Jira Login"]
16-
}
17-
18-
action "Jira Login" {
19-
uses = "atlassian/gajira-login@v1.0.0"
20-
secrets = ["JIRA_BASE_URL", "JIRA_USER_EMAIL", "JIRA_API_TOKEN"]
21-
}
22-
23-
action "Jira CLI" {
24-
needs = "Jira Login"
25-
uses = "atlassian/gajira-cli@v1.0.0"
26-
args = "--issue=GA-1 --comment=\"Actions in action\""
27-
}
12+
- name: Setup
13+
uses: atlassian/gajira-cli@master
14+
with:
15+
version: 1.0.20
2816
```
2917

30-
----
31-
## Action Spec
32-
### Reads fields from config file at $HOME/.jira.d/config.yml
33-
- `endpoint` - base URL of Jira instance
34-
- `email` - Jira user email
35-
36-
### Reads from $HOME/.jira.d/credentials
37-
- `JIRA_API_TOKEN` - Authentication token saved by [Jira Login Action](https://github.com/marketplace/actions/jira-login)
18+
#### Usage in later workflow steps
19+
```
20+
- name: Make comment on Jira issue
21+
run: jira --issue=GA-1 --comment=\"Actions in action\""
22+
```

‎action.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# JavaScript action
2+
name: setup-jira
3+
4+
description: Set up Jira CLI
5+
6+
inputs:
7+
version:
8+
description: Version of the CLI to use
9+
required: false
10+
default: 1.0.20
11+
12+
runs:
13+
using: 'node12'
14+
main: './dist/index.js'

‎dist/index.js

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

‎dist/unzip

170 KB
Binary file not shown.

‎dist/unzip-darwin

181 KB
Binary file not shown.

‎entrypoint.sh

-6
This file was deleted.

‎index.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const core = require('@actions/core');
2+
const cache = require('@actions/tool-cache');
3+
const semver = require('semver');
4+
const fs = require('fs').promises;
5+
6+
const toolName = 'jira';
7+
8+
async function exec() {
9+
try {
10+
let toolPath;
11+
const version = core.getInput('version');
12+
13+
// is this version already in our cache
14+
toolPath = cache.find(toolName, version);
15+
16+
if (!toolPath) {
17+
toolPath = await downloadCLI(version);
18+
}
19+
20+
// add tool to path for this and future actions to use
21+
core.addPath(toolPath);
22+
} catch (error) {
23+
core.setFailed(error.message);
24+
}
25+
}
26+
27+
async function downloadCLI(version) {
28+
const cleanVersion = semver.clean(version) || '';
29+
const downloadURL = encodeURI(`https://github.com/go-jira/jira/releases/download/v${cleanVersion}/jira-linux-amd64`);
30+
const downloadedTool = await cache.downloadTool(downloadURL);
31+
const permissions = 0o755;
32+
33+
await fs.chmod(downloadedTool, permissions);
34+
return await cache.cacheFile(downloadedTool, toolName, toolName, version);
35+
}
36+
37+
exec();

‎package-lock.json

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

‎package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "gajira-cli",
3+
"version": "1.0.0",
4+
"description": "Wrapped go-jira CLI action. Check out [go-jira documentation](https://github.com/Netflix-Skunkworks/go-jira) for more arguments and usage details",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "ncc build index.js --minify",
9+
"watch": "ncc build index.js --watch --minify"
10+
},
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"@actions/core": "^1.0.0",
15+
"@actions/tool-cache": "^1.1.0"
16+
},
17+
"devDependencies": {
18+
"@zeit/ncc": "^0.20.4"
19+
}
20+
}

0 commit comments

Comments
 (0)
Failed to load comments.