Skip to content

Commit 821f51c

Browse files
authored
fix: move template file content to variable (#20)
1 parent 89b589a commit 821f51c

File tree

6 files changed

+80
-222
lines changed

6 files changed

+80
-222
lines changed

ac.json

Lines changed: 0 additions & 72 deletions
This file was deleted.

dist/main/ac.json

Lines changed: 0 additions & 72 deletions
This file was deleted.

dist/main/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ac.json

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/main.ts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,83 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
33
import * as axios from 'axios'
4-
import * as fs from 'fs'
54
import {Template} from 'adaptivecards-templating'
65

6+
const temlpateData = {
7+
type: 'AdaptiveCard',
8+
body: [
9+
{
10+
type: 'TextBlock',
11+
size: 'large',
12+
weight: 'bolder',
13+
text:
14+
"Workflow '${$root.workflow.name}' #${$root.workflow.run_number} ${$root.workflow.conclusion}",
15+
color: '${$root.workflow.conclusion_color}',
16+
fontType: 'Default',
17+
separator: true
18+
},
19+
{
20+
type: 'TextBlock',
21+
text: 'on [${$root.repository.name}](${$root.repository.html_url})',
22+
wrap: true,
23+
spacing: 'None'
24+
},
25+
{
26+
type: 'ColumnSet',
27+
columns: [
28+
{
29+
type: 'Column',
30+
items: [
31+
{
32+
type: 'Image',
33+
style: 'Person',
34+
url: '${$root.author.avatar_url}',
35+
size: 'Medium'
36+
}
37+
],
38+
width: 'auto'
39+
},
40+
{
41+
type: 'Column',
42+
items: [
43+
{
44+
type: 'TextBlock',
45+
weight: 'Bolder',
46+
text: '[${$root.author.username}](${$root.author.html_url})',
47+
wrap: true
48+
}
49+
],
50+
width: 'stretch'
51+
}
52+
],
53+
spacing: 'Medium'
54+
},
55+
{
56+
type: 'FactSet',
57+
facts: [
58+
{
59+
title: 'Commit',
60+
value: '[${$root.commit.message}](${$root.commit.html_url})'
61+
},
62+
{
63+
title: '${$root.event.type}',
64+
value: '[${$root.event.html_url}](${$root.event.html_url})'
65+
},
66+
{
67+
title: 'Workflow run details',
68+
value:
69+
'[${$root.workflow.run_html_url}](${$root.workflow.run_html_url})'
70+
}
71+
],
72+
height: 'stretch',
73+
separator: true,
74+
spacing: 'Medium'
75+
}
76+
],
77+
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
78+
version: '1.2'
79+
}
80+
781
async function sleep(ms: number): Promise<unknown> {
882
return new Promise(resolve => {
983
setTimeout(resolve, ms)
@@ -79,7 +153,7 @@ const send = async () => {
79153
? TextBlockColor.Warning
80154
: TextBlockColor.Attention
81155

82-
const rawdata = fs.readFileSync('./ac.json').toString()
156+
const rawdata = JSON.stringify(temlpateData)
83157
const template = new Template(rawdata)
84158
const content = template.expand({
85159
$root: {

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5634,9 +5634,9 @@ xpath@^0.0.32:
56345634
integrity sha512-rxMJhSIoiO8vXcWvSifKqhvV96GjiD5wYb8/QHdoRyQvraTpp4IEv944nhGausZZ3u7dhQXteZuZbaqfpB7uYw==
56355635

56365636
y18n@^4.0.0:
5637-
version "4.0.0"
5638-
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
5639-
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
5637+
version "4.0.3"
5638+
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
5639+
integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
56405640

56415641
yallist@^3.0.2:
56425642
version "3.1.1"

0 commit comments

Comments
 (0)