Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(output): print output parameters #458

Merged
merged 13 commits into from Jun 3, 2021
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -19,7 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: ./
id: stale
with:
stale-issue-message: 'This issue is stale'
stale-pr-message: 'This PR is stale'
debug-only: true
- name: print outputs
run: echo ${{ join(steps.stale.outputs.*, ',') }}
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -21,19 +21,19 @@ $ npm test
Run the tests and display only the first failing tests :heavy_check_mark:

```bash
$ npm test:only-errors
$ npm run test:only-errors
```

Run the tests with the watch mode :heavy_check_mark:

```bash
$ npm test:watch
$ npm run test:watch
```

Run the linter and fix (almost) every issue for you :heavy_check_mark:

```bash
$ npm lint:all:fix
$ npm run lint:all:fix
```

# Before creating a PR
Expand All @@ -43,7 +43,7 @@ $ npm lint:all:fix
Build, lint, package and test everything.

```bash
$ npm all
$ npm run all
```

# Release
Expand Down
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -10,7 +10,7 @@ The default configuration will:

## All options

### List of options
### List of input options

Every argument is optional.

Expand Down Expand Up @@ -61,6 +61,13 @@ Every argument is optional.
| [exempt-all-pr-assignees](#exempt-all-pr-assignees) | Override [exempt-all-assignees](#exempt-all-assignees) for PRs only | |
| [enable-statistics](#enable-statistics) | Display statistics in the logs | `true` |

### List of output options

| Output | Description |
| ----------------- | -------------------------------------------- |
| staled-issues-prs | List of all staled issues and pull requests. |
| closed-issues-prs | List of all closed issues and pull requests. |

### Detailed options

#### repo-token
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Expand Up @@ -168,6 +168,11 @@ inputs:
description: 'Display some statistics at the end regarding the stale workflow (only when the logs are enabled).'
default: 'true'
required: false
outputs:
closed-issues-prs:
description: 'List of all closed issues and pull requests.'
staled-issues-prs:
description: 'List of all staled issues and pull requests.'
runs:
using: 'node12'
main: 'dist/index.js'
3,779 changes: 1,858 additions & 1,921 deletions dist/index.js

Large diffs are not rendered by default.

35 changes: 30 additions & 5 deletions package-lock.json

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

17 changes: 16 additions & 1 deletion src/main.ts
Expand Up @@ -2,12 +2,19 @@ import * as core from '@actions/core';
import {IssuesProcessor} from './classes/issues-processor';
import {isValidDate} from './functions/dates/is-valid-date';
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
import {Issue} from './classes/issue';

async function _run(): Promise<void> {
try {
const args = _getAndValidateArgs();

await new IssuesProcessor(args).processIssues();
const issueProcessor: IssuesProcessor = new IssuesProcessor(args);
await issueProcessor.processIssues();

await processOutput(
issueProcessor.closedIssues,
issueProcessor.staleIssues
);
} catch (error) {
core.error(error);
core.setFailed(error.message);
Expand Down Expand Up @@ -103,6 +110,14 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
return args;
}

async function processOutput(
staledIssues: Issue[],
closedIssues: Issue[]
): Promise<void> {
core.setOutput('staled-issues-prs', JSON.stringify(staledIssues));
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
}

function _toOptionalBoolean(
argumentName: Readonly<string>
): boolean | undefined {
Expand Down