File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 5757 STATIC : " ${{ inputs.static == 'true' && 'ON' || 'OFF' }}"
5858 TIME_TRACE : " ${{ inputs.time_trace == 'true' && 'ON' || 'OFF' }}"
5959 PACKAGE : " ${{ inputs.package == 'true' && 'ON' || 'OFF' }}"
60+ # GitHub creates merge commits for pull requests, so we need to use `github.event.pull_request.head.sha`
61+ # to get the actual commit SHA of the PR branch.
62+ GITHUB_HEAD_SHA : " ${{ github.event.pull_request.head.sha || github.sha }}"
6063 run : |
6164 cmake \
6265 -B "${BUILD_DIR}" \
Original file line number Diff line number Diff line change @@ -30,11 +30,17 @@ else ()
3030 OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY
3131 )
3232
33- set (GIT_COMMAND rev-parse --short HEAD)
34- execute_process (
35- COMMAND ${GIT_EXECUTABLE} ${GIT_COMMAND} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE REV
36- OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY
37- )
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
36+ set (REV $ENV{GITHUB_HEAD_SHA} )
37+ else ()
38+ set (GIT_COMMAND rev-parse --short HEAD)
39+ execute_process (
40+ COMMAND ${GIT_EXECUTABLE} ${GIT_COMMAND} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE REV
41+ OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY
42+ )
43+ endif ()
3844
3945 set (CLIO_VERSION "${DATE} -${BRANCH} -${REV} " )
4046 set (DOC_CLIO_VERSION "develop" )
You can’t perform that action at this time.
0 commit comments