diff --git a/README.md b/README.md index 4166110..f55c3b9 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,8 @@ This action provides the following outputs: - Currently, code coverage profiles are uploaded as GitHub artifacts which automatically expire after 90 days. In a repository which receives changes only infrequently, this might lead to issues when trying to compare - the code coverage of a pull request with the code coverage of the main branch (see fgrosse/go-coverage-report#5). + the code coverage of a pull request with the code coverage of the main branch (see fgrosse/go-coverage-report#5). + As a workaround, consider using `workflow_dispatch`. - Support **for forks** is limited since the necessary `GITHUB_TOKEN` permissions don't allow to post comments to the pull request of the base repository (see fgrosse/go-coverage-report#15). If forks are important for you, this action might not be the best solution. diff --git a/scripts/github-action.sh b/scripts/github-action.sh index 77993d5..cfe30c6 100755 --- a/scripts/github-action.sh +++ b/scripts/github-action.sh @@ -101,7 +101,12 @@ end_group start_group "Download code coverage results from target branch" LAST_SUCCESSFUL_RUN_ID=$(gh run list --status=success --branch="$TARGET_BRANCH" --workflow="$GITHUB_BASELINE_WORKFLOW" --event=push --json=databaseId --limit=1 -q '.[] | .databaseId') if [ -z "$LAST_SUCCESSFUL_RUN_ID" ]; then - echo "::error::No successful run found on the target branch" + echo "::warning::No successful run found for 'push' event. Checking for 'workflow_dispatch' event..." + LAST_SUCCESSFUL_RUN_ID=$(gh run list --status=success --branch="$TARGET_BRANCH" --workflow="$GITHUB_BASELINE_WORKFLOW" --event=workflow_dispatch --json=databaseId --limit=1 -q '.[] | .databaseId') +fi + +if [ -z "$LAST_SUCCESSFUL_RUN_ID" ]; then + echo "::error::No successful run found on the target branch for 'push' or 'workflow_dispatch' events." exit 1 fi