Skip to content

Commit

Permalink
Made issue creation customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeyexl committed Jul 17, 2024
1 parent 982259c commit d5c4ea2
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit d5c4ea2

Please sign in to comment.