@@ -31,6 +31,7 @@ You can use the following environment variables to configure the script:
3131- CHANGED_FILES_PATH: The path to the file containing the list of changed files (default: .github/outputs/all_modified_files.json)
3232- ROOT_PACKAGE: The import path of the tested repository to add as a prefix to all paths of the changed files (optional)
3333- TRIM_PACKAGE: Trim a prefix in the \" Impacted Packages\" column of the markdown report (optional)
34+ - SKIP_COMMENT: Skip creating or updating the pull request comment (default: false)
3435"
3536
3637if [[ $# != 3 ]]; then
4243GITHUB_REPOSITORY=$1
4344GITHUB_PULL_REQUEST_NUMBER=$2
4445GITHUB_RUN_ID=$3
45-
4646GITHUB_WORKFLOW=${GITHUB_WORKFLOW:- CI}
4747TARGET_BRANCH=${GITHUB_BASE_REF:- main}
4848COVERAGE_ARTIFACT_NAME=${COVERAGE_ARTIFACT_NAME:- code-coverage}
@@ -52,6 +52,7 @@ OLD_COVERAGE_PATH=.github/outputs/old-coverage.txt
5252NEW_COVERAGE_PATH=.github/outputs/new-coverage.txt
5353COVERAGE_COMMENT_PATH=.github/outputs/coverage-comment.md
5454CHANGED_FILES_PATH=${CHANGED_FILES_PATH:- .github/ outputs/ all_modified_files.json}
55+ SKIP_COMMENT=${SKIP_COMMENT:- false}
5556
5657if [[ -z ${GITHUB_REPOSITORY+x} ]]; then
5758 echo " Missing github_repository argument"
@@ -68,6 +69,13 @@ if [[ -z ${GITHUB_RUN_ID+x} ]]; then
6869 exit 1
6970fi
7071
72+ if [[ -z ${GITHUB_OUTPUT+x} ]]; then
73+ echo " Missing GITHUB_OUTPUT environment variable"
74+ exit 1
75+ fi
76+
77+ export GH_REPO=" $GITHUB_REPOSITORY "
78+
7179start_group (){
7280 echo " ::group::$* "
7381 { set -x; return ; } 2> /dev/null
@@ -107,7 +115,20 @@ go-coverage-report \
107115end_group
108116
109117if [ ! -s $COVERAGE_COMMENT_PATH ]; then
110- echo " ::notice::No coverage report to comment"
118+ echo " ::notice::No coverage report to output"
119+ exit 0
120+ fi
121+
122+ # Output the coverage report as a multiline GitHub output parameter
123+ echo " Writing GitHub output parameter to \" $GITHUB_OUTPUT \" "
124+ {
125+ echo " coverage_report<<END_OF_COVERAGE_REPORT"
126+ cat " $COVERAGE_COMMENT_PATH "
127+ echo " END_OF_COVERAGE_REPORT"
128+ } >> " $GITHUB_OUTPUT "
129+
130+ if [ " $SKIP_COMMENT " = " true" ]; then
131+ echo " Skipping pull request comment (\$ SKIP_COMMENT=true))"
111132 exit 0
112133fi
113134
0 commit comments