From 825388add359f232e467bb6d7ab5d255268025f6 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Tue, 31 Dec 2024 17:10:39 +0300 Subject: [PATCH] Update support for `workflow_dispatch` --- README.md | 3 ++- scripts/github-action.sh | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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