UNPKG

6.17 kBTypeScriptView Raw
1export declare const SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
2export declare const SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
3export declare type SummaryTableRow = (SummaryTableCell | string)[];
4export interface SummaryTableCell {
5 /**
6 * Cell content
7 */
8 data: string;
9 /**
10 * Render cell as header
11 * (optional) default: false
12 */
13 header?: boolean;
14 /**
15 * Number of columns the cell extends
16 * (optional) default: '1'
17 */
18 colspan?: string;
19 /**
20 * Number of rows the cell extends
21 * (optional) default: '1'
22 */
23 rowspan?: string;
24}
25export interface SummaryImageOptions {
26 /**
27 * The width of the image in pixels. Must be an integer without a unit.
28 * (optional)
29 */
30 width?: string;
31 /**
32 * The height of the image in pixels. Must be an integer without a unit.
33 * (optional)
34 */
35 height?: string;
36}
37export interface SummaryWriteOptions {
38 /**
39 * Replace all existing content in summary file with buffer contents
40 * (optional) default: false
41 */
42 overwrite?: boolean;
43}
44declare class Summary {
45 private _buffer;
46 private _filePath?;
47 constructor();
48 /**
49 * Finds the summary file path from the environment, rejects if env var is not found or file does not exist
50 * Also checks r/w permissions.
51 *
52 * @returns step summary file path
53 */
54 private filePath;
55 /**
56 * Wraps content in an HTML tag, adding any HTML attributes
57 *
58 * @param {string} tag HTML tag to wrap
59 * @param {string | null} content content within the tag
60 * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
61 *
62 * @returns {string} content wrapped in HTML element
63 */
64 private wrap;
65 /**
66 * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
67 *
68 * @param {SummaryWriteOptions} [options] (optional) options for write operation
69 *
70 * @returns {Promise<Summary>} summary instance
71 */
72 write(options?: SummaryWriteOptions): Promise<Summary>;
73 /**
74 * Clears the summary buffer and wipes the summary file
75 *
76 * @returns {Summary} summary instance
77 */
78 clear(): Promise<Summary>;
79 /**
80 * Returns the current summary buffer as a string
81 *
82 * @returns {string} string of summary buffer
83 */
84 stringify(): string;
85 /**
86 * If the summary buffer is empty
87 *
88 * @returns {boolen} true if the buffer is empty
89 */
90 isEmptyBuffer(): boolean;
91 /**
92 * Resets the summary buffer without writing to summary file
93 *
94 * @returns {Summary} summary instance
95 */
96 emptyBuffer(): Summary;
97 /**
98 * Adds raw text to the summary buffer
99 *
100 * @param {string} text content to add
101 * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
102 *
103 * @returns {Summary} summary instance
104 */
105 addRaw(text: string, addEOL?: boolean): Summary;
106 /**
107 * Adds the operating system-specific end-of-line marker to the buffer
108 *
109 * @returns {Summary} summary instance
110 */
111 addEOL(): Summary;
112 /**
113 * Adds an HTML codeblock to the summary buffer
114 *
115 * @param {string} code content to render within fenced code block
116 * @param {string} lang (optional) language to syntax highlight code
117 *
118 * @returns {Summary} summary instance
119 */
120 addCodeBlock(code: string, lang?: string): Summary;
121 /**
122 * Adds an HTML list to the summary buffer
123 *
124 * @param {string[]} items list of items to render
125 * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
126 *
127 * @returns {Summary} summary instance
128 */
129 addList(items: string[], ordered?: boolean): Summary;
130 /**
131 * Adds an HTML table to the summary buffer
132 *
133 * @param {SummaryTableCell[]} rows table rows
134 *
135 * @returns {Summary} summary instance
136 */
137 addTable(rows: SummaryTableRow[]): Summary;
138 /**
139 * Adds a collapsable HTML details element to the summary buffer
140 *
141 * @param {string} label text for the closed state
142 * @param {string} content collapsable content
143 *
144 * @returns {Summary} summary instance
145 */
146 addDetails(label: string, content: string): Summary;
147 /**
148 * Adds an HTML image tag to the summary buffer
149 *
150 * @param {string} src path to the image you to embed
151 * @param {string} alt text description of the image
152 * @param {SummaryImageOptions} options (optional) addition image attributes
153 *
154 * @returns {Summary} summary instance
155 */
156 addImage(src: string, alt: string, options?: SummaryImageOptions): Summary;
157 /**
158 * Adds an HTML section heading element
159 *
160 * @param {string} text heading text
161 * @param {number | string} [level=1] (optional) the heading level, default: 1
162 *
163 * @returns {Summary} summary instance
164 */
165 addHeading(text: string, level?: number | string): Summary;
166 /**
167 * Adds an HTML thematic break (<hr>) to the summary buffer
168 *
169 * @returns {Summary} summary instance
170 */
171 addSeparator(): Summary;
172 /**
173 * Adds an HTML line break (<br>) to the summary buffer
174 *
175 * @returns {Summary} summary instance
176 */
177 addBreak(): Summary;
178 /**
179 * Adds an HTML blockquote to the summary buffer
180 *
181 * @param {string} text quote text
182 * @param {string} cite (optional) citation url
183 *
184 * @returns {Summary} summary instance
185 */
186 addQuote(text: string, cite?: string): Summary;
187 /**
188 * Adds an HTML anchor tag to the summary buffer
189 *
190 * @param {string} text link text/content
191 * @param {string} href hyperlink
192 *
193 * @returns {Summary} summary instance
194 */
195 addLink(text: string, href: string): Summary;
196}
197/**
198 * @deprecated use `core.summary`
199 */
200export declare const markdownSummary: Summary;
201export declare const summary: Summary;
202export {};