Skip to content

Commit

Permalink
Use github.workflow_ref to fix issues when workflow files are renamed (
Browse files Browse the repository at this point in the history
…#41)

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

* Add CHANGELOG entry
  • Loading branch information
fgrosse authored Aug 23, 2024
1 parent fa9959d commit ba3f798
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit ba3f798

Please sign in to comment.