Skip to content

Commit 60ad8c7

Browse files
authored
feat(File): Output issues (objects including nodeId), not just issue URLs (#891)
Fixes github/continuous-ai-for-accessibility#33 This PR adds new `closed_issues`, `opened_issues`, and `reopened_issues` outputs to the ‘File’ action, and marks the existing `closed_issue_urls`, `opened_issue_urls`, and `reopened_issue_urls` outputs as deprecated (to be removed in v2). By continuing to output them in the v1 series, this change is non-breaking. The new outputs include both `url` and `nodeId`, so we don’t have to look-up the latter (again) in ‘Fix’. This conserves request quota and makes hitting rate limits less likely (github/continuous-ai-for-accessibility#31).
2 parents 4b8d98c + f94fa1e commit 60ad8c7

File tree

4 files changed

+76
-15
lines changed

4 files changed

+76
-15
lines changed

.github/actions/file/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,26 @@ List of potential accessibility gaps (plus issue URLs), as stringified JSON. For
3636
'[]'
3737
```
3838

39+
#### `closed_issues`
40+
41+
List of closed issues’ `id`, `nodeId`, `url`, and `title`, as stringified JSON. For example: `'[{"id":1,"nodeId":"SXNzdWU6MQ==","url":"https://github.com/github/docs/issues/123","title":"Accessibility issue: 1"},{"id":2,"nodeId":"SXNzdWU6Mg==","url":"https://github.com/github/docs/issues/124","title":"Accessibility issue: 2"},{"id":4,"nodeId":"SXNzdWU6NA==","url":"https://github.com/github/docs/issues/126","title":"Accessibility issue: 4"}]'`.
42+
43+
#### `opened_issues`
44+
45+
List of newly-opened issues’ `id`, `nodeId`, `url`, and `title`, as stringified JSON. For example: `'[{"id":1,"nodeId":"SXNzdWU6MQ==","url":"https://github.com/github/docs/issues/123","title":"Accessibility issue: 1"},{"id":2,"nodeId":"SXNzdWU6Mg==","url":"https://github.com/github/docs/issues/124","title":"Accessibility issue: 2"},{"id":4,"nodeId":"SXNzdWU6NA==","url":"https://github.com/github/docs/issues/126","title":"Accessibility issue: 4"}]'`.
46+
47+
#### `repeated_issues`
48+
49+
List of repeated issues’ `id`, `nodeId`, `url`, and `title`, as stringified JSON. For example: `'[{"id":1,"nodeId":"SXNzdWU6MQ==","url":"https://github.com/github/docs/issues/123","title":"Accessibility issue: 1"},{"id":2,"nodeId":"SXNzdWU6Mg==","url":"https://github.com/github/docs/issues/124","title":"Accessibility issue: 2"},{"id":4,"nodeId":"SXNzdWU6NA==","url":"https://github.com/github/docs/issues/126","title":"Accessibility issue: 4"}]'`.
50+
3951
#### `closed_issue_urls`
4052

41-
List of URLs for closed issues, as stringified JSON. For example: `'["https://github.com/github/docs/issues/123","https://github.com/github/docs/issues/124","https://github.com/github/docs/issues/126","https://github.com/github/docs/issues/127"]'`.
53+
**DEPRECATED: This output will be removed in `v2`.** List of URLs for closed issues, as stringified JSON. For example: `'["https://github.com/github/docs/issues/123","https://github.com/github/docs/issues/124","https://github.com/github/docs/issues/126","https://github.com/github/docs/issues/127"]'`.
4254

4355
#### `opened_issue_urls`
4456

45-
List of URLs for newly-opened issues, as stringified JSON. For example: `'["https://github.com/github/docs/issues/123","https://github.com/github/docs/issues/124","https://github.com/github/docs/issues/126","https://github.com/github/docs/issues/127"]'`.
57+
**DEPRECATED: This output will be removed in `v2`.** List of URLs for newly-opened issues, as stringified JSON. For example: `'["https://github.com/github/docs/issues/123","https://github.com/github/docs/issues/124","https://github.com/github/docs/issues/126","https://github.com/github/docs/issues/127"]'`.
4658

4759
#### `repeated_issue_urls`
4860

49-
List of URLs for repeated issues, as stringified JSON. For example: `'["https://github.com/github/docs/issues/123","https://github.com/github/docs/issues/124","https://github.com/github/docs/issues/126","https://github.com/github/docs/issues/127"]'`.
61+
**DEPRECATED: This output will be removed in `v2`.** List of URLs for repeated issues, as stringified JSON. For example: `'["https://github.com/github/docs/issues/123","https://github.com/github/docs/issues/124","https://github.com/github/docs/issues/126","https://github.com/github/docs/issues/127"]'`.

.github/actions/file/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ inputs:
1818
outputs:
1919
findings:
2020
description: "List of potential accessibility gaps (plus issue URLs), as stringified JSON"
21+
closed_issues:
22+
description: "List of closed issues, as stringified JSON"
23+
opened_issues:
24+
description: "List of newly-opened issues, as stringified JSON"
25+
repeated_issues:
26+
description: "List of repeated issues, as stringified JSON"
2127
closed_issue_urls:
22-
description: "List of URLs for closed issues, as stringified JSON"
28+
description: "DEPRECATED: List of URLs for closed issues, as stringified JSON"
2329
opened_issue_urls:
24-
description: "List of URLs for newly-opened issues, as stringified JSON"
30+
description: "DEPRECATED: List of URLs for newly-opened issues, as stringified JSON"
2531
repeated_issue_urls:
26-
description: "List of URLs for repeated issues, as stringified JSON"
32+
description: "DEPRECATED: List of URLs for repeated issues, as stringified JSON"
2733

2834
runs:
2935
using: "node20"

.github/actions/file/src/index.ts

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Finding } from "./types.d.js";
1+
import type { Finding, Issue } from "./types.d.js";
22
import process from "node:process";
33
import core from "@actions/core";
44
import { Octokit } from "@octokit/core";
@@ -40,15 +40,27 @@ export default async function () {
4040
},
4141
}
4242
});
43-
const closedIssueUrls = [];
44-
const openedIssueUrls = [];
45-
const repeatIssueUrls = [];
43+
const closedIssues: Issue[] = [];
44+
const openedIssues: Issue[] = [];
45+
const repeatedIssues: Issue[] = [];
46+
/** @deprecated Use `closedIssues` instead. */
47+
const closedIssueUrls: string[] = [];
48+
/** @deprecated Use `openedIssues` instead. */
49+
const openedIssueUrls: string[] = [];
50+
/** @deprecated Use `repeatedIssues` instead. */
51+
const repeatedIssueUrls: string[] = [];
4652

4753
for (const cachedFinding of cachedFindings) {
4854
if (!findingsMap.has(`${cachedFinding.url};${cachedFinding.problemShort};${cachedFinding.html}`)) {
4955
try {
5056
// Finding was not found in the latest run, so close its issue (if necessary)
5157
const response = await closeIssueForFinding(octokit, repoWithOwner, cachedFinding);
58+
closedIssues.push({
59+
id: response.data.id,
60+
nodeId: response.data.node_id,
61+
url: response.data.html_url,
62+
title: response.data.title,
63+
});
5264
closedIssueUrls.push(response.data.html_url);
5365
core.info(`Closed issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
5466
} catch (error) {
@@ -66,10 +78,22 @@ export default async function () {
6678
finding.issueUrl = response.data.html_url;
6779
if (response.data.html_url === cachedIssueUrl) {
6880
// Finding was found in previous and latest runs, so reopen its issue (if necessary)
69-
repeatIssueUrls.push(response.data.html_url);
81+
repeatedIssues.push({
82+
id: response.data.id,
83+
nodeId: response.data.node_id,
84+
url: response.data.html_url,
85+
title: response.data.title,
86+
});
87+
repeatedIssueUrls.push(response.data.html_url);
7088
core.info(`Repeated issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
7189
} else {
7290
// New finding was found in the latest run, so create its issue
91+
openedIssues.push({
92+
id: response.data.id,
93+
nodeId: response.data.node_id,
94+
url: response.data.html_url,
95+
title: response.data.title,
96+
});
7397
openedIssueUrls.push(response.data.html_url);
7498
core.info(`Created issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
7599
}
@@ -79,13 +103,25 @@ export default async function () {
79103
}
80104
}
81105

106+
core.setOutput("closed_issues", JSON.stringify(closedIssues));
107+
core.setOutput("opened_issues", JSON.stringify(openedIssues));
108+
core.setOutput("repeated_issues", JSON.stringify(repeatedIssues));
109+
core.setOutput("findings", JSON.stringify(findings));
110+
core.debug(`Output: 'closed_issues: ${JSON.stringify(closedIssues)}'`);
111+
core.debug(`Output: 'opened_issues: ${JSON.stringify(openedIssues)}'`);
112+
core.debug(`Output: 'repeated_issues: ${JSON.stringify(repeatedIssues)}'`);
113+
core.debug(`Output: 'findings: ${JSON.stringify(findings)}'`);
114+
115+
// Deprecated outputs
82116
core.setOutput("closed_issue_urls", JSON.stringify(closedIssueUrls));
83117
core.setOutput("opened_issue_urls", JSON.stringify(openedIssueUrls));
84-
core.setOutput("repeated_issue_urls", JSON.stringify(repeatIssueUrls));
85-
core.setOutput("findings", JSON.stringify(findings));
118+
core.setOutput("repeated_issue_urls", JSON.stringify(repeatedIssueUrls));
119+
core.warning("The 'closed_issue_urls' output is deprecated and will be removed in v2. If you use the 'closed_issue_urls' output, please migrate to the 'closed_issues' output.");
86120
core.debug(`Output: 'closed_issue_urls: ${JSON.stringify(closedIssueUrls)}'`);
121+
core.warning("The 'opened_issue_urls' output is deprecated and will be removed in v2. If you use the 'opened_issue_urls' output, please migrate to the 'opened_issues' output.");
87122
core.debug(`Output: 'opened_issue_urls: ${JSON.stringify(openedIssueUrls)}'`);
88-
core.debug(`Output: 'repeated_issue_urls: ${JSON.stringify(repeatIssueUrls)}'`);
89-
core.debug(`Output: 'findings: ${JSON.stringify(findings)}'`);
123+
core.warning("The 'repeated_issue_urls' output is deprecated and will be removed in v2. If you use the 'repeated_issue_urls' output, please migrate to the 'repeated_issues' output.");
124+
core.debug(`Output: 'repeated_issue_urls: ${JSON.stringify(repeatedIssueUrls)}'`);
125+
90126
core.info("Finished 'file' action");
91127
}

.github/actions/file/src/types.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ export type Finding = {
88
solutionShort: string;
99
solutionLong?: string;
1010
issueUrl?: string;
11+
}
12+
13+
export type Issue = {
14+
id: number;
15+
nodeId: string;
16+
url: string;
17+
title: string;
1118
}

0 commit comments

Comments
 (0)