feat: @actions/core extensions for markdown summary#1014
Merged
Conversation
SrRyan
reviewed
Mar 3, 2022
jtamsut
reviewed
Mar 3, 2022
jtamsut
reviewed
Mar 3, 2022
jtamsut
reviewed
Mar 3, 2022
jtamsut
approved these changes
Mar 3, 2022
konradpabjan
approved these changes
Mar 4, 2022
LayZeeDK
reviewed
Mar 8, 2022
| * | ||
| * @returns {Promise<MarkdownSummary>} markdown summary instance | ||
| */ | ||
| async write(overwrite = false): Promise<MarkdownSummary> { |
There was a problem hiding this comment.
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?
Contributor
Author
There was a problem hiding this comment.
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!
ghost
approved these changes
Apr 12, 2022
yacaovsnc
approved these changes
Apr 20, 2022
Redmishiaomi
approved these changes
Aug 11, 2024
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_SUMMARYfile or.write(true)to completely overwrite the$GITHUB_STEP_SUMMARYfile.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.