Skip to content

Commit

Permalink
added action summary (#7)
Browse files Browse the repository at this point in the history
I discovered [this
feature](https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/)
recently and decided to add it.

It does look super cool in the action summary.
  • Loading branch information
Bullrich authored Apr 2, 2023
1 parent 7761ca8 commit 26282e0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getBooleanInput, getInput, getMultilineInput, info, setOutput } from "@actions/core";
import { getBooleanInput, getInput, getMultilineInput, info, setOutput, summary } from "@actions/core";
import { context, getOctokit } from "@actions/github";
import { Context } from "@actions/github/lib/context";
import moment from "moment";
Expand Down Expand Up @@ -81,15 +81,25 @@ const runAction = async (ctx: Context) => {
return {
url: issue.html_url,
title: issue.title,
daysStale: daysSinceDate(issue.updated_at)
daysStale: daysSinceDate(issue.updated_at),
number: issue.number
}
});

setOutput("data", JSON.stringify(cleanedData));
const message = generateMarkdownMessage(staleIssues, repo);
setOutput("message", message);

await summary.addHeading(`${repo.owner}/${repo.repo}`)
.addHeading(`${amountOfStaleIssues} stale issues`, 3)
.addTable([
[{ data: "Title", header: true }, { data: "Days stale", header: true }, { data: "Link", header: true }],
...cleanedData.map(issue => [issue.title, issue.daysStale.toString(), `${repo.owner}/${repo.repo}#${issue.number}`] as string[])
])
.addLink("See all issues", `https://github.com/${repo.owner}/${repo.repo}/issues`).write();
} else {
setOutput("message", `### Repo ${repo.owner}/${repo.repo} has no stale issues`);
await summary.addHeading(`${repo.owner}/${repo.repo}`).addHeading("No stale issues", 3).addEOL().write();
}
}

Expand Down

0 comments on commit 26282e0

Please sign in to comment.