Get additional workflow information about diskspace (#29705)

* Get additional workflow information about diskspace

* Get even more diskspace usage info

* Initial attempt at collecting info on disk space within checkout submodule

* Fix CI issue

* Another attempt to get CI running workflow grabbing diskspace usage

* Couple other fixes

* Another attempt to get CI running

* Try this new approach

* quick fix

* Dump more info

* Few more touch ups

* quick fix

* Restyle

* Restyle

* quick fix

* quick fix
diff --git a/.github/actions/checkout-submodules-and-bootstrap/action.yaml b/.github/actions/checkout-submodules-and-bootstrap/action.yaml
index 8226b7e..160e4fa 100644
--- a/.github/actions/checkout-submodules-and-bootstrap/action.yaml
+++ b/.github/actions/checkout-submodules-and-bootstrap/action.yaml
@@ -15,6 +15,8 @@
 runs:
   using: "composite"
   steps:
+    - name: Dump disk info
+      uses: ./.github/actions/dump-disk-info
     - name: Checkout submodules
       uses: ./.github/actions/checkout-submodules
       with:
@@ -26,6 +28,9 @@
       uses: ./.github/actions/bootstrap
       with:
         platform: ${{ inputs.platform }}
+    - name: Dump disk info after checkout submodule & Bootstrap
+      shell: bash
+      run: scripts/dump_diskspace_info.sh
     - name: Upload Bootstrap Logs
       uses: ./.github/actions/upload-bootstrap-logs
       with:
diff --git a/.github/actions/dump-disk-info/action.yaml b/.github/actions/dump-disk-info/action.yaml
new file mode 100644
index 0000000..1f6474e
--- /dev/null
+++ b/.github/actions/dump-disk-info/action.yaml
@@ -0,0 +1,20 @@
+name: Dump disk space info
+description: Help debug running out of disk space on github CI
+runs:
+  using: "composite"
+  steps:
+    - name: Collect disk info
+      # Unfortunately current syntax for github wrapper actions only work for
+      # Javascript actions, and Docker container actions, which doesn't make it
+      # possible to wrap a shell script like the one below. The action below
+      # essentially wraps the shell commands we want to run into a Javascript
+      # wrapped action. This allow us to get the disk info usage before a job
+      # is run and after the job is run regardless if the job succeeds or
+      # fails.
+      uses: pyTooling/Actions/with-post-step@v0.4.5
+      if: ${{ runner.os == 'Linux' }}
+      with:
+        main: |-
+          exec ./scripts/dump_diskspace_info.sh
+        post: |-
+          exec ./scripts/dump_diskspace_info.sh
\ No newline at end of file
diff --git a/scripts/dump_diskspace_info.sh b/scripts/dump_diskspace_info.sh
new file mode 100755
index 0000000..2e947f4
--- /dev/null
+++ b/scripts/dump_diskspace_info.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This script is meant to run in github CI to dump information related to
+# disk space usage. Currently there is a heisenbug related to running out
+# of disk space. Dumping information below might help us get a better
+# understanding of how disk space is used in github CI.
+
+echo "Disk Space Usage:"
+df -h
+
+listOfDirectories=("third_party/" ".environment/" "out/")
+
+pipCacheDir=$(python -m pip cache dir)
+exitcode=$?
+
+if [ "$exitcode" -eq 0 ]; then
+    listOfDirectories+=("$pipCacheDir")
+fi
+
+echo
+echo "Storage Space Used By Key Directories:"
+for directory in "${listOfDirectories[@]}"; do
+    if [ -d "$directory" ]; then
+        du -d1 -h "$directory" | sort -h
+        echo
+    fi
+done