diff --git a/README.md b/README.md index cee5881..cac24cc 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ jobs: - uses: doc-detective/github-action ``` +The action outputs the results of the command as a JSON-formatted string that you can use this in subsequent steps in the same job. See [`results`](#results). + ## File structure This action runs in the current working directory of the workflow. If you want to change the directory, you can do so by adding a `working-directory` key to the `github-action` step: @@ -126,6 +128,54 @@ jobs: createIssueOnFail: true ``` +### `issueTitle` (default: `Doc Detective Failure`) + +The title of the created GitHub issue. Only valid if `createIssueOnFail` is set to `true`. + +```yaml +- uses: doc-detective/github-action + with: + createIssueOnFail: true + issueTitle: Doc Detective found issues in the documentation +``` + +### `issueBody` (default: `Doc Detective run failed with the following results:\n$RESULTS`) + +he body of the created GitHub issue. Use the `$RESULTS` variable to insert the results object. Only valid if `createIssueOnFail` is set to `true`. + +```yaml +- uses: doc-detective/github-action + with: + createIssueOnFail: true + issueBody: | + Doc Detective found issues in the documentation. Review and fix the issues. + + Results: + $RESULTS +``` + +### `issueLabels` (default: `doc-detective`) + +Comma-separated list of labels to apply to the GitHub issue. Only valid if `createIssueOnFail` is set to `true`. + +```yaml +- uses: doc-detective/github-action + with: + createIssueOnFail: true + issueLabels: doc-detective,documentation +``` + +### `issueAssignees` + +Comma-separated list of GitHub usernames to assign to the GitHub issue. Only valid if `createIssueOnFail` is set to `true`. + +```yaml +- uses: doc-detective/github-action + with: + createIssueOnFail: true + issueAssignees: octocat,monalisa +``` + ### `token` (default: `${{ github.token }}`) The GitHub token to use for creating issues. Defaults to the token already available to the GitHub Action workflow. Only set this if you want to override the default token. diff --git a/action.yml b/action.yml index d366dfe..8295624 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,22 @@ inputs: description: Create a GitHub issue if one or more tests fails. Default is "false". Only valid for the "runTests" command. required: false default: "false" + issueTitle: + description: The title of the created GitHub issue. Only valid if "createIssueOnFail" is set to "true". + required: false + default: "Doc Detective Failure" + issueBody: + description: The body of the created GitHub issue. Use the `$RESULTS` variable to insert the results object. Only valid if "createIssueOnFail" is set to "true". + required: false + default: "Doc Detective run failed with the following results:\n$RESULTS" + issueLabels: + description: Comma-separated list of labels to apply to the GitHub issue. Only valid if "createIssueOnFail" is set to "true". + required: false + default: "doc-detective" + issueAssignees: + description: Comma-separated list of GitHub usernames to assign to the GitHub issue. Only valid if "createIssueOnFail" is set to "true". + required: false + default: "" token: description: The GitHub token to use for creating issues. Defaults to the token already available to the GitHub Action workflow. Only set this if you want to override the default token. required: false diff --git a/index.js b/index.js index 96e6358..c1387e1 100644 --- a/index.js +++ b/index.js @@ -72,12 +72,12 @@ async function main() { async function createIssue(results) { // Attempt to get the token from action input; fall back to GITHUB_TOKEN environment variable const token = core.getInput("token"); - const octokit = github.getOctokit(token); + const title = core.getInput("issueTitle"); + const body = core.getInput("issueBody").replace("$RESULTS", JSON.stringify(results, null, 2)); + const labels = core.getInput("issueLabels"); + const assignees = core.getInput("issueAssignees"); - const title = "Failure in Doc Detective run"; - const body = `Doc Detective run failed with the following results:\n${results}`; - const labels = "doc-detective"; - const assignees = ""; + const octokit = github.getOctokit(token); const issue = await octokit.rest.issues.create({ owner: github.context.repo.owner, diff --git a/package-lock.json b/package-lock.json index 182b83b..de9203a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "doc-detective-github-action", - "version": "0.0.1-beta.1", + "version": "0.0.1-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "doc-detective-github-action", - "version": "0.0.1-beta.1", + "version": "0.0.1-beta.2", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", diff --git a/package.json b/package.json index 8ea7c1f..260f18f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "doc-detective-github-action", - "version": "0.0.1-beta.1", + "version": "0.0.1-beta.2", "description": "Validate doc content by treating docs as testable assertions for a product.", "main": "index.js", "scripts": {