generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b5cfbf
commit 125f313
Showing
2 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as core from "@actions/core"; | ||
import { Context } from "../types"; | ||
|
||
export interface ResultInfo { | ||
url: string; | ||
merged: boolean; | ||
} | ||
|
||
function generateGitHubSummary(context: Context, urls: ResultInfo[]): string { | ||
let monitored = context.config.repos.monitor.join(" | ") + "\n\n"; | ||
const ignored = context.config.repos.ignore.join(" | ") + "\n\n"; | ||
|
||
monitored += | ||
ignored + | ||
urls | ||
.map(({ url, merged }) => { | ||
const status = merged ? `<span style="color:green">merged</span>` : `<span style="color:grey">no change</span>`; | ||
return `- [${url}](${url}) - ${status}`; | ||
}) | ||
.join("\n"); | ||
|
||
return monitored; | ||
} | ||
|
||
export async function generateSummary(context: Context, results: ResultInfo[]) { | ||
try { | ||
const summary = generateGitHubSummary(context, results); | ||
await core.summary.addRaw(summary).write(); | ||
} catch (e) { | ||
context.logger.error("Could not publish the summary", { e }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters