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

Use github.workflow_ref to fix issues when workflow files are renamed #41

Merged
merged 2 commits into from
Aug 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
_Nothing so far_
- Fix issue when the workflow file is renamed (fgrosse/go-coverage-report#41)

## [v1.1.0] - 2024-07-25
- Document permissions needed to use this action (fgrosse/go-coverage-report#32)
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ runs:
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
GITHUB_WORKFLOW: ${{ github.workflow }}
GITHUB_WORKFLOW_REF: ${{ github.workflow_ref }}
GITHUB_BASE_REF: ${{ github.base_ref }}
CHANGED_FILES_PATH: .github/outputs/all_modified_files.json
COVERAGE_ARTIFACT_NAME: ${{ inputs.coverage-artifact-name }}
Expand Down
6 changes: 6 additions & 0 deletions scripts/github-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ this in the workflow file:

You can use the following environment variables to configure the script:
- GITHUB_WORKFLOW: The name of the Workflow (default: CI)
- GITHUB_WORKFLOW_REF: The ref path to the workflow to use instead of GITHUB_WORKFLOW (optional)
- GITHUB_BASE_REF: The base branch to compare the coverage results against (default: main)
- COVERAGE_ARTIFACT_NAME: The name of the artifact containing the code coverage results (default: code-coverage)
- COVERAGE_FILE_NAME: The name of the file containing the code coverage results (default: coverage.txt)
Expand Down Expand Up @@ -74,6 +75,11 @@ if [[ -z ${GITHUB_OUTPUT+x} ]]; then
exit 1
fi

# If GITHUB_WORKFLOW_REF is defined, extract the workflow file path from it and use it instead of GITHUB_WORKFLOW
if [[ -n ${GITHUB_WORKFLOW_REF+x} ]]; then
GITHUB_WORKFLOW=$(basename "${GITHUB_WORKFLOW_REF%%@*}")
fi

export GH_REPO="$GITHUB_REPOSITORY"

start_group(){
Expand Down
Loading