Skip to content

Commit e36aff0

Browse files
committed
Fix download url
1 parent 71e0336 commit e36aff0

File tree

4 files changed

+19
-30
lines changed

4 files changed

+19
-30
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
- name: Upload Reports
2929
uses: actions/upload-artifact@v5
3030
with:
31-
name: reports
31+
name: Full reports
3232
path: running/reports

src/artifact.ts

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
11
import { DefaultArtifactClient } from "@actions/artifact";
22
import * as github from "@actions/github";
33
import * as path from "path";
4-
import { getOctokit } from "./octokit.ts";
54
import { writeFile } from "./utilities.ts";
5+
import { type Repository } from "./repositories.ts";
66

77
export async function uploadToArtifact(
8-
texts: string[],
8+
reports: { repository: Repository; diff: string }[],
99
): Promise<string | undefined> {
10-
if (texts.length === 0) {
11-
return undefined;
12-
}
13-
1410
const GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE!;
1511

1612
const files = await Promise.all(
17-
texts.map(async (text) => {
18-
const file = Date.now().toString() + ".diff";
19-
20-
await writeFile(path.join(GITHUB_WORKSPACE, file), text);
21-
13+
reports.map(async ({ repository, diff }) => {
14+
const file = `${repository.directoryName}.path`;
15+
await writeFile(path.join(GITHUB_WORKSPACE, file), diff);
2216
return file;
2317
}),
2418
);
2519

2620
const artifactClient = new DefaultArtifactClient();
27-
const artifactName = "reports-" + Date.now().toString();
28-
await artifactClient.uploadArtifact(artifactName, files, GITHUB_WORKSPACE);
29-
30-
const octokit = getOctokit();
31-
const {
32-
data: { artifacts },
33-
} = await octokit.rest.actions.listWorkflowRunArtifacts({
34-
owner: github.context.repo.owner,
35-
repo: github.context.repo.repo,
36-
run_id: github.context.runId,
37-
});
38-
console.log(artifacts);
21+
const artifactName = "Partial reports";
22+
const uploaded = await artifactClient.uploadArtifact(
23+
artifactName,
24+
files,
25+
GITHUB_WORKSPACE,
26+
);
3927

40-
const artifactData = artifacts.find((a) => a.name === artifactName);
41-
console.log(artifactData);
28+
const url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}/artifacts/${uploaded.id}`;
4229

43-
return artifactData!.archive_download_url;
30+
return url;
4431
}

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ async function run() {
5252

5353
const { title, reports } = getReport(result);
5454

55-
const filesToUpload = reports
56-
.flatMap((group) => group.results.filter((report) => report.shouldUpload))
57-
.map((report) => report.diff);
55+
const filesToUpload = reports.flatMap((group) =>
56+
group.results.filter((report) => report.shouldUpload),
57+
);
5858

5959
let artifactUrl: string | undefined;
6060

src/report.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function getReport({
4242
reports: {
4343
length: number;
4444
results: {
45+
repository: Repository;
4546
head: string;
4647
diff: string;
4748
shouldUpload: boolean;
@@ -70,6 +71,7 @@ export function getReport({
7071
/* Some room for blank lines */ 50;
7172
const shouldUpload = length > MAXIMUM_GITHUB_COMMENT_LENGTH;
7273
return {
74+
repository,
7375
head,
7476
diff,
7577
shouldUpload,

0 commit comments

Comments
 (0)