Creates an issue even if inputs.issue_labels is not given (#21)

* Creates an issue even if inputs.issue_labels is not given

* 1.0.0

* Use v1.0.0 in example, daily scan
This commit is contained in:
Naoki Oketani
2019-12-09 22:49:41 +09:00
committed by GitHub
parent be0cdcbe10
commit 2e5ad3c2cf
7 changed files with 20 additions and 16 deletions

View File

@@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: install dependencies - name: install dependencies
run: npm ci run: npm ci
- uses: oke-py/npm-audit-action@v0.1.0 - uses: oke-py/npm-audit-action@v1.0.0
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue_assignees: oke-py issue_assignees: oke-py

View File

@@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: install dependencies - name: install dependencies
run: npm ci run: npm ci
- uses: oke-py/npm-audit-action@v0.1.0 - uses: oke-py/npm-audit-action@v1.0.0
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
issue_assignees: oke-py issue_assignees: oke-py

View File

@@ -8,8 +8,8 @@ describe('getIssueOption', () => {
const expected: IssueOption = { const expected: IssueOption = {
title: 'npm audit found vulnerabilities', title: 'npm audit found vulnerabilities',
body: 'hi', body: 'hi',
assignees: [''], assignees: undefined,
labels: [''] labels: undefined
} }
expect(issue.getIssueOption('hi')).toEqual(expected) expect(issue.getIssueOption('hi')).toEqual(expected)
}) })

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "npm-audit-action", "name": "npm-audit-action",
"version": "0.1.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "npm-audit-action", "name": "npm-audit-action",
"version": "0.1.0", "version": "1.0.0",
"private": true, "private": true,
"description": "GitHub Action to run `npm audit`", "description": "GitHub Action to run `npm audit`",
"main": "lib/main.js", "main": "lib/main.js",

View File

@@ -2,16 +2,20 @@ import * as core from '@actions/core'
import {IssueOption} from './interface' import {IssueOption} from './interface'
export function getIssueOption(body: string): IssueOption { export function getIssueOption(body: string): IssueOption {
let assignees
let labels
if (core.getInput('issue_assignees')) {
assignees = core.getInput('issue_assignees').replace(/\s+/g, '').split(',')
}
if (core.getInput('issue_labels')) {
labels = core.getInput('issue_labels').replace(/\s+/g, '').split(',')
}
return { return {
title: core.getInput('issue_title'), title: core.getInput('issue_title'),
body, body,
assignees: core assignees,
.getInput('issue_assignees') labels
.replace(/\s+/g, '')
.split(','),
labels: core
.getInput('issue_labels')
.replace(/\s+/g, '')
.split(',')
} }
} }

View File

@@ -3,8 +3,8 @@ import * as github from '@actions/github'
import stripAnsi from 'strip-ansi' import stripAnsi from 'strip-ansi'
import Octokit, {IssuesCreateResponse} from '@octokit/rest' import Octokit, {IssuesCreateResponse} from '@octokit/rest'
import {Audit} from './audit' import {Audit} from './audit'
import * as issue from '../src/issue' import * as issue from './issue'
import {IssueOption} from '../src/interface' import {IssueOption} from './interface'
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {