Skip to content

Commit 659784f

Browse files
committed
Make branch name work as well
1 parent ea7d5b6 commit 659784f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.github/actions/cmake/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ runs:
5959
PACKAGE: "${{ inputs.package == 'true' && 'ON' || 'OFF' }}"
6060
# GitHub creates merge commits for pull requests, so we need to use `github.event.pull_request.head.sha`
6161
# to get the actual commit SHA of the PR branch.
62+
GITHUB_REF_NAME: "${{ github.ref_name }}"
6263
GITHUB_HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
6364
run: |
6465
cmake \

cmake/ClioVersion.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ else ()
2424
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY
2525
)
2626

27-
set(GIT_COMMAND branch --show-current)
28-
execute_process(
29-
COMMAND ${GIT_EXECUTABLE} ${GIT_COMMAND} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE BRANCH
30-
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY
31-
)
32-
33-
if (DEFINED ENV{GITHUB_HEAD_SHA})
34-
# GitHub creates merge commits for pull requests, so we need to use `github.event.pull_request.head.sha` to get the
35-
# actual commit SHA of the PR branch. We set $GITHUB_HEAD_SHA in the cmake action
27+
if (DEFINED ENV{GITHUB_CI})
28+
# GitHub in PR doesn't: - keep branch name - run from commit pushed to branch
29+
set(BRANCH $ENV{GITHUB_REF_NAME})
3630
set(REV $ENV{GITHUB_HEAD_SHA})
3731
else ()
32+
set(GIT_COMMAND branch --show-current)
33+
execute_process(
34+
COMMAND ${GIT_EXECUTABLE} ${GIT_COMMAND} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE BRANCH
35+
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY
36+
)
37+
3838
set(GIT_COMMAND rev-parse --short HEAD)
3939
execute_process(
4040
COMMAND ${GIT_EXECUTABLE} ${GIT_COMMAND} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE REV

0 commit comments

Comments
 (0)