Skip to content

Add github step summary #24

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ jobs:
uses: ./
with:
args: --include-submodules lint --json
summary: json
- name: REUSE SPDX SBOM
uses: ./
with:
args: spdx
summary: none

# Use all major version of the action
test-v1:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ In the same fashion, it is possible to add optional arguments like `--include-su
| Name | Requirement | Default | Description |
| ------ | ----------- | ------- | ----------- |
| `args` | _required_ | `lint` | The subcommand for the REUSE helper tool. Read the [tool's documentation](https://reuse.readthedocs.io/) for all available subcommands. |
| `summary` | _required_ | `markdown` | Whether or not to include the tool output in the github step summary markdown. Set to `json` to format the tools output in a codeblock or to `none` to disable this output. Regardless of this option the output will still be visible in the logs. |

## Versions

Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ runs:
branding:
icon: 'check-circle'
color: 'green'

inputs:
summary:
description: "Show your REUSE compliance report in the github step summary using markdown (`markdown`), a json codeblock (`json`) or not at all (`none`)"
required: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a default. why is it mandatory?

default: 'markdown'

20 changes: 19 additions & 1 deletion reuse-action-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,23 @@ git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Enter directory
cd "$GITHUB_WORKSPACE" || exit 1

echo "Summary type (should be json, markdown, or none): $INPUT_SUMMARY"

if ! [ "$INPUT_SUMMARY" = "none" ]; then
# Add header to step summary
echo "# REUSE Compliance Status" >>"$GITHUB_STEP_SUMMARY"
fi

if [ "$INPUT_SUMMARY" = "json" ]; then
# Add code block header to step summary
printf '\n```json\n' >>"$GITHUB_STEP_SUMMARY"
fi

# Run REUSE
reuse "$@"
reuse "$@" | (if ! [ "$INPUT_SUMMARY" = "none" ]; then tee -a "$GITHUB_STEP_SUMMARY"; else cat; fi)

if [ "$INPUT_SUMMARY" = "json" ]; then
# Add code block footer to step summary
printf '\n```\n' >>"$GITHUB_STEP_SUMMARY"
fi