Skip to content

Commit e7529d0

Browse files
committed
chore: update qrcode
1 parent 2810a8a commit e7529d0

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ with:
3131
| ms\_teams\_webhook | Microsoft Teams Webhook | |
3232
| title | Title | |
3333
| description | Description | |
34+
| qrcode | Text | |
3435

3536
- Config telegram bot, get chat id: [CONFIG_TELEGRAM_BOT](https://github.com/hunghg255/action-notifications/blob/master/CONFIG_TELEGRAM_BOT.md)
3637

action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ inputs:
4242
description: "Job status. Should be bound to job.status. Default to success."
4343
required: false
4444
default: ${{ job.status }}
45-
45+
qrcode:
46+
description: "Display with qrcode"
47+
required: false

lib/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"@actions/exec": "^1.1.1",
2121
"@actions/github": "^5.1.1",
2222
"@actions/io": "^1.1.3",
23-
"axios": "^1.5.0"
23+
"axios": "^1.5.0",
24+
"hqr": "^0.0.3"
2425
},
2526
"homepage": "https://github.com/hunghg255/action-notifications",
2627
"repository": {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export type TInputs = {
99
title?: string;
1010
description?: string;
1111
status?: string;
12+
qrcode?: string;
1213
}

src/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { fitEmbed } from './validate';
77
import { formatEventSlack } from './slack/format';
88
import { formatEventTelegram, escapeMarkdownUrl } from './telegram/format';
99
import { formatEventGoogleChat } from './google-chat/format';
10+
import { renderBase64 } from 'hqr';
1011

1112
export const statusOpts: Record<string, any> = {
1213
success: {
@@ -44,6 +45,7 @@ export const getInputs = (): TInputs => {
4445
const status = getInput('status').trim() || '';
4546
const title = getInput('title').trim() || '';
4647
const description = getInput('description').trim() || '';
48+
const qrcode = getInput('qrcode').trim() || '';
4749
telegram_bot_token;
4850

4951
return {
@@ -57,6 +59,7 @@ export const getInputs = (): TInputs => {
5759
title,
5860
description,
5961
status,
62+
qrcode
6063
};
6164
};
6265

@@ -93,6 +96,7 @@ export function getPayloadDiscord(inputs: Readonly<TInputs>): Object {
9396
statusOpts[inputs.status as any].status +
9497
(embed.title ? `: ${embed.title}` : '');
9598

99+
96100
if (inputs.description) embed.description = inputs.description;
97101

98102
embed.fields = [
@@ -123,9 +127,16 @@ export function getPayloadDiscord(inputs: Readonly<TInputs>): Object {
123127
},
124128
];
125129

130+
if (inputs.qrcode) {
131+
embed.thumbnail = {
132+
url: renderBase64(inputs.qrcode)
133+
}
134+
}
135+
126136
let discord_payload: any = {
127137
embeds: [fitEmbed(embed)],
128138
};
139+
129140
logDebug(`embed: ${JSON.stringify(embed)}`);
130141

131142
// if (inputs.username) {

0 commit comments

Comments
 (0)