Skip to content
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

Update output display to job summary #3914

Merged
merged 3 commits into from Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -48,6 +48,8 @@

<!-- For example, Docker, GitHub Actions, pre-commit, editors -->

- The action output displayed in the job summary is now wrapped in Markdown (#3914)

### Documentation

<!-- Major changes to documentation and policies. Small docs changes
Expand Down
18 changes: 16 additions & 2 deletions action.yml
Expand Up @@ -36,10 +36,24 @@ runs:
- name: black
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
python $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY
runner="python"
else
python3 $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY
runner="python3"
fi

out=$(${runner} $GITHUB_ACTION_PATH/action/main.py)
exit_code=$?

# Display the raw output in the step
echo "${out}"

# Display the Markdown output in the job summary
echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY
echo "${out}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

# Exit with the exit-code returned by Black
exit ${exit_code}
env:
# TODO: Remove once https://github.com/actions/runner/issues/665 is fixed.
INPUT_OPTIONS: ${{ inputs.options }}
Expand Down