diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index d328de3..89d3c88 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v1 - name: install dependencies run: npm ci - - uses: oke-py/npm-audit-action@v0.1.0 + - uses: oke-py/npm-audit-action@v1.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} issue_assignees: oke-py diff --git a/README.md b/README.md index c57fc06..dce5777 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ jobs: - uses: actions/checkout@v1 - name: install dependencies run: npm ci - - uses: oke-py/npm-audit-action@v0.1.0 + - uses: oke-py/npm-audit-action@v1.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} issue_assignees: oke-py diff --git a/__tests__/issue.test.ts b/__tests__/issue.test.ts index 46581d4..81530d7 100644 --- a/__tests__/issue.test.ts +++ b/__tests__/issue.test.ts @@ -8,8 +8,8 @@ describe('getIssueOption', () => { const expected: IssueOption = { title: 'npm audit found vulnerabilities', body: 'hi', - assignees: [''], - labels: [''] + assignees: undefined, + labels: undefined } expect(issue.getIssueOption('hi')).toEqual(expected) }) diff --git a/package-lock.json b/package-lock.json index c6fd7ff..563bb49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "npm-audit-action", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2e0a658..70f1421 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "npm-audit-action", - "version": "0.1.0", + "version": "1.0.0", "private": true, "description": "GitHub Action to run `npm audit`", "main": "lib/main.js", diff --git a/src/issue.ts b/src/issue.ts index 22d9da5..aafd657 100644 --- a/src/issue.ts +++ b/src/issue.ts @@ -2,16 +2,20 @@ import * as core from '@actions/core' import {IssueOption} from './interface' 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 { title: core.getInput('issue_title'), body, - assignees: core - .getInput('issue_assignees') - .replace(/\s+/g, '') - .split(','), - labels: core - .getInput('issue_labels') - .replace(/\s+/g, '') - .split(',') + assignees, + labels } } diff --git a/src/main.ts b/src/main.ts index 2565fb2..7bf21b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,8 +3,8 @@ import * as github from '@actions/github' import stripAnsi from 'strip-ansi' import Octokit, {IssuesCreateResponse} from '@octokit/rest' import {Audit} from './audit' -import * as issue from '../src/issue' -import {IssueOption} from '../src/interface' +import * as issue from './issue' +import {IssueOption} from './interface' async function run(): Promise { try {