Skip to content

Commit 1a692e6

Browse files
Auto add safe directory
1 parent fbaa43b commit 1a692e6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tools/cmake/mbed_submodule_management.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ git submodule update --init ${SUBMODULE_PATH}")
6363

6464
# Clone the submodule if not done already
6565
if(NOT SUBMODULE_CLONED)
66+
67+
# Github Actions has an issue where the clone of the repo is done as a different user
68+
# https://github.com/actions/checkout/issues/47
69+
# This causes an error like 'fatal: unsafe repository ('/__w/mbed-os/mbed-os' is owned by someone else)'
70+
# Other than chown-ing the source directory after the checkout step, it seems like the only fix
71+
# is to run the following command if we detect Github Actions
72+
if(NOT "$ENV{GITHUB_RUN_ID}" STREQUAL "")
73+
execute_process(
74+
COMMAND ${GIT_EXECUTABLE} config --global --add safe.directory ${CMAKE_SOURCE_DIR}
75+
COMMAND_ERROR_IS_FATAL ANY
76+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
77+
)
78+
endif()
79+
80+
6681
if(MBED_USE_SHALLOW_SUBMODULES)
6782
set(SHALLOW_ARGS --depth 1)
6883
else()

0 commit comments

Comments
 (0)