New feature announced here. Here's the full documentation.
These are incredibly easy to use. GitHub creates a file in your workspace and puts the filename in $GITHUB_STEP_SUMMARY
, so you can build the summary markdown over multiple steps like this:
echo "{markdown content}" >> $GITHUB_STEP_SUMMARY
I decided to try this out in my simonw/pypi-datasette-packages repo, which runs a daily Git scraper that records a copy of the PyPI JSON for packages within the Datasette ecosystem.
I ended up mixing it with the Git commit code, so the step now looks like this:
- name: Commit and push
run: |-
git config user.name "Automated"
git config user.email "actions@users.noreply.github.com"
git add -A
timestamp=$(date -u)
git commit -m "${timestamp}" || exit 0
echo '### Changed files' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
git show --name-only --format=tformat: >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
git pull --rebase
git push
This produces a summary that looks like this:
Two things I had to figure out here. First, the backtick needs escaping if used in double quotes but does not in single quotes:
echo '```' >> $GITHUB_STEP_SUMMARY
I wanted to show just the list of affected filenames from the most recent Git commit. That's what this does:
git show --name-only --format=tformat:
Without the --format=tformat
bit this shows the full commit message and header in addition to the list of files.
I'm running this in the same block as the other git
commands so that this line will terminate the step early without writing to the summary file if there are no changes to be committed:
git commit -m "${timestamp}" || exit 0
Created 2022-05-17T10:28:21-07:00, updated 2022-05-17T10:49:39-07:00 · History · Edit