Skip to content

WcAServices/markdown-template-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown Template Action

Quickly build markdown summaries for your workflows.

  • Supports environment variable injection
  • Allows you to write summaries in YAML
  • Much easier deal with comparing with inline bash summaries.

Example usage

The following is an extract from our example-template.yml workflow. You can see it in action by going to the Actions tab in this repo.

steps:
  - uses: WcAServices/markdown-template-action@v1
    with:
      # These will be injected into the below template, in addition to GitHub's standard
      # variables. You can perform string operations here as well.
      variables: >-
        GREETING="world"
        COMMIT_SHA="${{ github.sha }}"
        SHORT_SHA=${COMMIT_SHA:0:7}
        
      # The following language="..." comment enables syntax highlighting in JetBrains IDEs
      
      # language="markdown"
      template: |
         # Hello, $GREETING
         > ### You're on commit [`$SHORT_SHA`]($COMMIT_SHA)            

         ##### Standard GitHub variables should work too:
         ```yaml
         Github Ref: $GITHUB_REF
         Commit author: $GITHUB_ACTOR
         Job: $GITHUB_JOB
         ```
      

Result

Once your workflow has completed, you'll receive a nice summary at the bottom of the page with your markdown template. Using the workflow above, you should end up with something like the following;

image

Reasoning

When building step summaries, you tend to get stuck with GitHub's suggested apporoach where you simply echo into the step summary variable. This can quickly get very verbose when you get into slightly more advanced markdown formatting:

  • A great alternative to the following templating workflow; 👎

    echo "# Tests are failing"                                         >> $GITHUB_STEP_SUMMARY
    echo "> Go blame $GITHUB_ACTOR who pushed to $GITHUB_BASE_REF"     >> $GITHUB_STEP_SUMMARY
    echo ""                                                            >> $GITHUB_STEP_SUMMARY
    echo '```'                                                         >> $GITHUB_STEP_SUMMARY
    echo "$TEST_SUMMARY_RESULTS"                                       >> $GITHUB_STEP_SUMMARY
    echo '```'                                                         >> $GITHUB_STEP_SUMMARY