GitHub Action Summary Examples

It would be really great if you could provide example code for the samples seen in the blog post: Supercharging GitHub Actions with Job Summaries | The GitHub Blog.

Using @actions/core I’m unable to successfully reproduce a table with links in the cell like in one of the examples.

Thanks

1 Like

:wave:t2: Hi @zricethezav Welcome back to the forums!! Thanks for this feedback on the blog post from @konradpabjan - I’m tagging them in this thread so they can see it :eyes:

In case it’s helpful for you or anyone else who comes across this thread: Here are a couple of other posts on Actions that might be helpful:

Thanks again for the feedback on the blog! :sparkles:

1 Like

Hi @ettaboyle,

I appreciate the links. I’ve definitely spent some time combing through the docs and blog posts on GitHub Actions. Great stuff all around!

Specifically for my original post I was hoping to find an example of a GitHub Action either:

  1. rendering markdown using the @actions/core node library
    or
  2. nesting core.summary objects. so for example, being able to nest .addLink within .addTable would be nice. It looks like this is in the example of Markdown tables and hover cards with @mentions in the blog.

Thanks

Zach

1 Like

core.summary isn’t designed to render Markdown nor to support nesting.

The methods generate HTML, apparently the subset that is allowed on GitHub in Markdown, but there is nothing to take Markdown in and output the corresponding HTML. AFAIK, you can generally have HTML in Markdown, and the outer Markdown will be rendered as expected, but if you nest Markdown in HTML in Markdown, the inner Markdown won’t be rendered.

The problem with the addLink() and other methods is that they append to an internal buffer. The addTable() method would need them to return the generated HTML as a string, however. You can’t make use of the wrap() method either, because it is defined as private. What should work is to pass HTML strings to addTable(). You could copy some of the toolkit code to your own code to make generating HTML a little bit more convenient.

Other than that, I don’t see how you could utilized the toolkit code for what you asked for, but feel free to take a look at the code for yourself:

2 Likes

@Simran-B thank you for your response. So for the examples in the blog post, those were all created using run: echo ... >> $GITHUB_STEP_SUMMARY?

1 Like

I think so, yeah. They are easy to create in Markdown. On the other hand, using HTML or core.summary has the advantage that you can make use of colspan and rowspan in tables.

Here are some examples from the blog post with links in a table. Hope this helps! :slightly_smiling_face:

    steps:
    - name: Add markdown
      run: | 
        echo "## :rocket: Pull Request Succesfully Deployed! :rocket:" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "14 Kubernetes Containers successfully updated with the [following binaries]()" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "Useful Links" >> $GITHUB_STEP_SUMMARY
        echo "- [Deployment Guide]()" >> $GITHUB_STEP_SUMMARY
        echo "- [Deployment confidence dashboard]()" >> $GITHUB_STEP_SUMMARY
        echo "- [Incoming Alerts]()" >> $GITHUB_STEP_SUMMARY
        echo "- [On-Call Engineers]()" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "If things go :fire:" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "|[:bangbang:  Rollback](https://github.com/)| [:pager:  Status]()|" >> $GITHUB_STEP_SUMMARY
        echo "|---|---|" >> $GITHUB_STEP_SUMMARY

and

    steps:
    - name: Adding markdown
      run: |
        echo "## Train pull request analysis" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "|     Author(s)       |           Commits          |  Files Changed  | File Removed  |  Merge SHA |" >> $GITHUB_STEP_SUMMARY
        echo "| ------------------- | -------------------------- | --------------- |---------------|--------------|" >> $GITHUB_STEP_SUMMARY
        echo "|   @robherley        |              4             |     13          |       4       |   [3a70d5cad]()      |" >> $GITHUB_STEP_SUMMARY
        echo "|   @pfleidi          |              3             |     2           |       8       |   [6d20562ae]()      |" >> $GITHUB_STEP_SUMMARY
        echo "|   @konradpabjan     |              1             |     1           |       0       |   [dc4d0a278]()      |" >> $GITHUB_STEP_SUMMARY
1 Like