File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 3030 with :
3131 build-mount-path : /var/lib/docker/tmp
3232
33+ test-mount-parent-of-workspace :
34+ name : Test mounting the parent of GITHUB_WORKSPACE
35+ runs-on : ubuntu-latest
36+ steps :
37+ - name : Check out Maximize Build Space action
38+ uses : actions/checkout@v4
39+ with :
40+ path : ./.github/actions/maximize-test
41+
42+ - name : Calculate parent of workspace
43+ id : workspace-parent
44+ run : echo "parent=$(dirname "${GITHUB_WORKSPACE}")" >> "$GITHUB_OUTPUT"
45+
46+ - name : Maximize build space
47+ uses : ./.github/actions/maximize-test
48+ with :
49+ build-mount-path : ${{ steps.workspace-parent.outputs.parent }}
50+
51+ - name : Create file in build folder as runner user (test ownership)
52+ run : |
53+ mkdir -p ${{ steps.workspace-parent.outputs.parent }}/new
54+ touch ${{ steps.workspace-parent.outputs.parent }}/new/file.txt
55+ touch ${GITHUB_WORKSPACE}/file.txt
56+ ls -alR ${{ steps.workspace-parent.outputs.parent }}
57+
3358 determine-free-space :
3459 name : Determine free space with different settings
3560 runs-on : ${{ matrix.os }}
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments