-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: @actions/core extensions for markdown summary #1014
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
* | ||
* @returns {Promise<MarkdownSummary>} markdown summary instance | ||
*/ | ||
async write(overwrite = false): Promise<MarkdownSummary> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is the write(overwrite: boolean)
pattern used elsewhere in the toolkit? Did you consider write(options: { overwrite: boolean })
to leave room for future options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe it's an existing pattern. I do like the idea of having an options object for extensibility. And I think it'll improve readability as well, ie: write(true)
vs write({overwrite: true})
. I'll make the changes, thanks for the suggestion!
Closes: https://github.com/github/c2c-actions-checks/issues/280
This exposes a new class instance to
@actions/core
,core.markdownSummary
. It's a singleton that has an internal buffer with utility methods to facilitate the creation of HTML elements in a markdown summary for a job.The API is designed to be chainable, like the following:
Would result in:
👉 HTML 👈
👉 Rendered markdown 👈
Test Results
📚 View raw output
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Or, since a buffer is built internally it can be used like so:
Would result in:
👉 HTML 👈
👉 Rendered markdown 👈
one
two
three
four
five
six
Any
markdownSummary.add*
method first adds to an internal buffer. It is not until the final.write()
that it gets append to the$GITHUB_STEP_SUMMARY
file or.write(true)
to completely overwrite the$GITHUB_STEP_SUMMARY
file.If the users requires custom markup, the
.add()
method allows for raw text to be added to the buffer. Utility methods likeemptyBuffer()
to empty a buffer without writing andisBufferEmpty()
are included as well.Since all the actual rendering gets passed through dotcom's HTML rendering pipeline we don't need to worry about sanitizing any of the data.