Skip to content

Commit

Permalink
Add color helper to all badge colors
Browse files Browse the repository at this point in the history
  • Loading branch information
greggbjensen committed Aug 25, 2024
1 parent d0ca92a commit fe74026
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions prdeploy-webhooks/src/services/template-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Handlebars.registerHelper('jsonEncode', (text: string) => {
return JSON.stringify(text);
});

Handlebars.registerHelper('color', hexValue => (hexValue ? hexValue.replace(/^#/, '') : ''));

export type TemplateNames =
| 'deploy-started.md'
| 'deploy-completed.json'
Expand All @@ -27,8 +29,6 @@ export type TemplateNames =
| 'rollback-started.md'
| 'services-not-found.md';

Handlebars.registerHelper('color', hexValue => (hexValue ? hexValue.replace(/^#/, '') : ''));

@scoped(Lifecycle.ContainerScoped)
export class TemplateService {
private static readonly templates = new Map<string, TemplateDelegate<any>>();
Expand Down
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/deploy-completed.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#if isRollback}}\[ROLLBACK\] {{/if}}[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Deploy%20Complete/{{badge.statusColors.success}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
{{#if isRollback}}\[ROLLBACK\] {{/if}}[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Deploy%20Complete/{{color badge.statusColors.success}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/deploy-failed.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{#if isRollback}}[ROLLBACK] {{/if}}[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Deploy%20Failed/{{badge.statusColors.error}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
{{#if isRollback}}[ROLLBACK] {{/if}}[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Deploy%20Failed/{{color badge.statusColors.error}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
{{message}}
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/deploy-nothing-found.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/No%20Deploys%20Found/{{badge.statusColors.error}}?labelColor={{color environment.color}}&icon=github&scale=1.2)
![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/No%20Deploys%20Found/{{color badge.statusColors.error}}?labelColor={{color environment.color}}&icon=github&scale=1.2)
Nothing found to deploy, make a change to a file in the service you want to include.
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/deploy-started.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Deploy%20Started/{{badge.statusColors.info}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Deploy%20Started/{{color badge.statusColors.info}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
{{#if environment.requireApproval}}
[Approve deployment](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}}) to continue
{{/if}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Checks%20Incomplete/{{badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Checks%20Incomplete/{{color badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
The following checks are incomplete:
{{#each incompleteChecks}}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Check%20Runs%20Complete/{{badge.statusColors.info}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Check%20Runs%20Complete/{{color badge.statusColors.info}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
Triggered a new deployment
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/pull-request-enqueued.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/No%20Environment%20Available/{{badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/No%20Environment%20Available/{{color badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
{{#if alreadyInQueue}}
Your pull request is already in the queue at position {{queuePosition}}.
{{else}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Merge%20Conflicts/{{badge.statusColors.error}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Merge%20Conflicts/{{color badge.statusColors.error}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
This branch is out-of-date with the base branch and there are merge conflicts
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/pull-request-updated.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Branch%20Updated/{{badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Branch%20Updated/{{color badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)]({{prdeployPortalUrl}}/{{owner}}/{{repo}}?environment={{environment.name}} 'Open the queue')
{{updateMessage}}
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/rollback-completed.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Rollback%20Complete/{{badge.statusColors.success}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Rollback%20Complete/{{color badge.statusColors.success}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/rollback-started.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Rollback%20Started/{{badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
[![{{environment.name}}](https://badgen.net/badge/{{environment.name}}/Rollback%20Started/{{color badge.statusColors.warn}}?labelColor={{color environment.color}}&icon=github&scale=1.2)](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}} 'Open the deploy')
{{#if environment.requireApproval}}
[Approve deployment](https://github.com/{{owner}}/{{repo}}/actions/runs/{{run.id}}/attempts/{{run.run_attempt}}) to continue
{{/if}}
2 changes: 1 addition & 1 deletion prdeploy-webhooks/templates/services-not-found.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Add](https://badgen.net/badge/Add/Services%20Not%20Found/{{badge.statusColors.error}}?labelColor=000000&icon=github&scale=1.2)
![Add](https://badgen.net/badge/Add/Services%20Not%20Found/{{color badge.statusColors.error}}?labelColor=000000&icon=github&scale=1.2)
The following services are not configured:
{{#each services}}

Expand Down

0 comments on commit fe74026

Please sign in to comment.