diff --git a/README.md b/README.md index a3c5587..c12ccb4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ [Requirements](#requirements) | [Configuration](#configuration) | [Publishing new release](#publishing-new-release) `eslint-remote-tester-run-action` is a pre-configured Github workflow action for running [`eslint-remote-tester`](https://github.com/AriPerkkio/eslint-remote-tester). -It runs `eslint-remote-tester` and posts results in Github issue. Results are commented on existing open issue if present. +It runs `eslint-remote-tester` and posts results in Github issue. +Results are commented on existing **open** issue if present. Existing issues are searched based on `issue-label` if present. Otherwise `issue-title` will be used. Check out the use case description from eslint-remote-tester's documentation: [Plugin maintainer making sure all existing rules do not crash](https://github.com/AriPerkkio/eslint-remote-tester#plugin-maintainer-making-sure-all-existing-rules-do-not-crash). @@ -50,6 +51,7 @@ jobs: - uses: AriPerkkio/eslint-remote-tester-run-action@v2 with: issue-title: 'Results of weekly scheduled smoke test' + issue-label: 'smoke-test' max-result-count: 100 eslint-remote-tester-config: test/smoke/eslint-remote-tester.config.js ``` @@ -60,6 +62,7 @@ jobs: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :--------------------------------------------: | :----------------------------------------- | | `github-token` | Token for Github Authentication. See [About the `GITHUB_TOKEN` secret](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret). | :x: | `${{github.token}}` | `${{secrets.SOME_CUSTOM_TOKEN}}` | | `issue-title` | Title of issue created for reporting results | :x: | `'Results of eslint-remote-tester-run-action'` | `'Results of weekly scheduled smoke test'` | +| `issue-label` | Label used on the created issue | :x: | :x: | `'smoke-test'` | | `eslint-remote-tester-config` | Path to project's `eslint-remote-tester.config.js` | :x: | `'eslint-remote-tester.config.js'` | `./path/to/custom.config.js` | | `max-result-count` | Maximum result count to be posted in result comment. | :x: | `50` | `100` | | `working-directory` | The working directory where action is run | :x: | :x: | `./ci` | diff --git a/action.yml b/action.yml index 679d173..eca45d6 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,9 @@ inputs: description: 'Title of issue created for reporting results' reqired: false default: 'Results of eslint-remote-tester-run-action' + issue-label: + description: 'Label used on the created issue' + reqired: false eslint-remote-tester-config: description: 'Path to eslint-remote-tester.config.js' reqired: false diff --git a/dist/index.js b/dist/index.js index 6fea9b7..f0519c4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5763,9 +5763,11 @@ var core = __toModule(require_core()); var import_github = __toModule(require_github()); var githubToken; var issueTitle; +var issueLabel; try { githubToken = core.getInput("github-token"); issueTitle = core.getInput("issue-title", {required: true}); + issueLabel = core.getInput("issue-label"); } catch (error2) { core.setFailed(error2.message); } @@ -5801,11 +5803,12 @@ var GithubClient = class { })); } async getExistingIssue() { + const query = issueLabel ? `label:"${issueLabel}"` : `${issueTitle} in:title`; const response = await this.requestAndRetry(() => this.octokit.search.issuesAndPullRequests({ sort: "created", order: "desc", q: [ - `${issueTitle} in:title`, + query, "is:issue", "is:open", `repo:${import_github.context.repo.owner}/${import_github.context.repo.repo}` @@ -5821,6 +5824,7 @@ var GithubClient = class { owner: import_github.context.repo.owner, repo: import_github.context.repo.repo, title: issueTitle, + labels: issueLabel ? [issueLabel] : void 0, body })); } diff --git a/src/github-client.ts b/src/github-client.ts index 30b8caa..cbca370 100644 --- a/src/github-client.ts +++ b/src/github-client.ts @@ -3,10 +3,12 @@ import { context, getOctokit } from '@actions/github'; let githubToken: string; let issueTitle: string; +let issueLabel: string | undefined; try { githubToken = core.getInput('github-token'); issueTitle = core.getInput('issue-title', { required: true }); + issueLabel = core.getInput('issue-label'); } catch (error) { core.setFailed(error.message); } @@ -68,12 +70,17 @@ class GithubClient { } private async getExistingIssue(): Promise { + // Look for existing issues based on issue label if present. Otherwise use issue title + const query = issueLabel + ? `label:"${issueLabel}"` + : `${issueTitle} in:title`; + const response = await this.requestAndRetry(() => this.octokit.search.issuesAndPullRequests({ sort: 'created', order: 'desc', q: [ - `${issueTitle} in:title`, + query, 'is:issue', 'is:open', `repo:${context.repo.owner}/${context.repo.repo}`, @@ -95,6 +102,7 @@ class GithubClient { owner: context.repo.owner, repo: context.repo.repo, title: issueTitle, + labels: issueLabel ? [issueLabel] : undefined, body, }) );