Skip to content

Commit fadc013

Browse files
committed
fix: recreate GITHUB_WORKSPACE with correct owner when deleted
1 parent cd652e0 commit fadc013

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

action.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ runs:
111111
fi
112112
echo
113113
114+
# store owner of $GITHUB_WORKSPACE in case the action deletes it
115+
WORKSPACE_OWNER="$(stat -c '%U:%G' "${GITHUB_WORKSPACE}")"
116+
114117
# ensure mount path exists before the action
115118
sudo mkdir -p "${BUILD_MOUNT_PATH}"
116119
sudo find "${BUILD_MOUNT_PATH}" -maxdepth 0 ! -empty -exec echo 'WARNING: directory [{}] is not empty, data loss might occur. Content:' \; -exec ls -al "{}" \;
@@ -182,8 +185,11 @@ runs:
182185
sudo mount "/dev/mapper/${VG_NAME}-buildlv" "${BUILD_MOUNT_PATH}"
183186
sudo chown -R "${{ inputs.build-mount-path-ownership }}" "${BUILD_MOUNT_PATH}"
184187
185-
# if build mount path is a parent of $GITHUB_WORKSPACE, recreate it
186-
sudo mkdir -p "${GITHUB_WORKSPACE}"
188+
# if build mount path is a parent of $GITHUB_WORKSPACE, and has been deleted, recreate it
189+
if [[ ! -d "${GITHUB_WORKSPACE}" ]]; then
190+
sudo mkdir -p "${GITHUB_WORKSPACE}"
191+
sudo chown -R "${WORKSPACE_OWNER}" "${GITHUB_WORKSPACE}"
192+
fi
187193
188194
- name: Disk space report after modification
189195
shell: bash

0 commit comments

Comments
 (0)