Skip to content

Commit

Permalink
Merge pull request #15 from gentlementlegen/feat/job-summary
Browse files Browse the repository at this point in the history
feat: job summary
  • Loading branch information
gentlementlegen authored Aug 22, 2024
2 parents e0f4b64 + a58485a commit 0eddb9d
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/handlers/summary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from "@actions/core";
import { parseGitHubUrl } from "../helpers/github";
import { Context } from "../types";

export interface ResultInfo {
Expand All @@ -7,18 +8,31 @@ export interface ResultInfo {
}

function generateGitHubSummary(context: Context, urls: ResultInfo[]): string {
let output = "## Repositories\n\n";
output += `Monitored: [${context.config.repos.monitor.join(" | ")}]\n\n`;
output += `Ignored: [${context.config.repos.ignore.join(" | ")}]\n\n`;
output += "## Merging\n\n";
output += "🟢: merged\n🔵: no change\n\n";
output += urls
.map(({ url, merged }) => {
const status = merged ? `<span>🟢</span>` : `<span>🔵</span>`;
return `- ${status} - [${url}](${url})`;
})
.join("\n");
return output;
const target = `https://github.com/${context.payload.repository.owner?.login}`;
const output: string[] = ["## Merge report\n\n"];
output.push("<samp>\n");
output.push("| Merged | ID |");
output.push("|---|---|");
output.push(
urls
.sort((a) => (a.merged ? -1 : 1))
.map(({ url, merged }) => {
const status = merged ? `<span>🔵</span>` : `<span>⚫️</span>`;
const { repo, issue_number } = parseGitHubUrl(url);
return `| ${status} | [${repo}#${issue_number}](${url}) |`;
})
.join("\n")
);
output.push("\n");
output.push("🔵 = merged");
output.push("⚫️ = unmerged");
output.push("\n</samp>\n");
output.push("## Configuration\n\n");
output.push("### Watching Repositories\n\n");
output.push(context.config.repos.monitor.map((o) => `- [${o}](${target}/${o})`).join("\n"));
output.push("### Ignored Repositories\n\n");
output.push(context.config.repos.ignore.map((o) => `- [${o}](${target}/${o})`).join("\n"));
return output.join("\n");
}

export async function generateSummary(context: Context, results: ResultInfo[]) {
Expand Down

0 comments on commit 0eddb9d

Please sign in to comment.