Files
electron/.github/workflows/macos-disk-cleanup.yml
dependabot[bot] fe0caa0e0d build(deps): bump actions/checkout from 6.0.0 to 6.0.1 (#49158)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.0 to 6.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1af3b93b68...8e8c483db8)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-09 11:14:41 -05:00

105 lines
3.4 KiB
YAML

name: macOS Disk Space Cleanup
# Description:
# This workflow runs the disk space reclaimer on macOS runners every night
# and logs disk space metrics to Datadog for monitoring.
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
permissions: {}
jobs:
macos-disk-cleanup:
strategy:
fail-fast: false
matrix:
runner:
- macos-15
- macos-15-large
- macos-15-xlarge
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
sparse-checkout: |
.github/actions/free-space-macos
sparse-checkout-cone-mode: false
- name: Get Disk Space Before Cleanup
id: disk-before
shell: bash
run: |
echo "Disk space before cleanup:"
df -h /
FREE_SPACE_BEFORE=$(df -k / | tail -1 | awk '{print $4}')
echo "free_kb=$FREE_SPACE_BEFORE" >> $GITHUB_OUTPUT
- name: Free Space on macOS
uses: ./.github/actions/free-space-macos
- name: Get Disk Space After Cleanup
id: disk-after
shell: bash
run: |
echo "Disk space after cleanup:"
df -h /
FREE_SPACE_AFTER=$(df -k / | tail -1 | awk '{print $4}')
echo "free_kb=$FREE_SPACE_AFTER" >> $GITHUB_OUTPUT
- name: Log Disk Space to Datadog
if: ${{ env.DD_API_KEY != '' }}
shell: bash
env:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
FREE_BEFORE: ${{ steps.disk-before.outputs.free_kb }}
FREE_AFTER: ${{ steps.disk-after.outputs.free_kb }}
MATRIX_RUNNER: ${{ matrix.runner }}
run: |
TIMESTAMP=$(date +%s)
FREE_BEFORE_GB=$(echo "scale=2; $FREE_BEFORE / 1024 / 1024" | bc)
FREE_AFTER_GB=$(echo "scale=2; $FREE_AFTER / 1024 / 1024" | bc)
SPACE_FREED_GB=$(echo "scale=2; ($FREE_AFTER - $FREE_BEFORE) / 1024 / 1024" | bc)
echo "Free space before: ${FREE_BEFORE_GB}GB"
echo "Free space after: ${FREE_AFTER_GB}GB"
echo "Space freed: ${SPACE_FREED_GB}GB"
curl -s -X POST "https://api.datadoghq.com/api/v2/series" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-d @- << EOF
{
"series": [
{
"metric": "electron.macos.disk.free_space_before_cleanup_gb",
"points": [{"timestamp": ${TIMESTAMP}, "value": ${FREE_BEFORE_GB}}],
"type": 3,
"unit": "gigabyte",
"tags": ["runner:${MATRIX_RUNNER}", "platform:macos"]
},
{
"metric": "electron.macos.disk.free_space_after_cleanup_gb",
"points": [{"timestamp": ${TIMESTAMP}, "value": ${FREE_AFTER_GB}}],
"type": 3,
"unit": "gigabyte",
"tags": ["runner:${MATRIX_RUNNER}", "platform:macos"]
},
{
"metric": "electron.macos.disk.space_freed_gb",
"points": [{"timestamp": ${TIMESTAMP}, "value": ${SPACE_FREED_GB}}],
"type": 3,
"unit": "gigabyte",
"tags": ["runner:${MATRIX_RUNNER}", "platform:macos"]
}
]
}
EOF
echo "Disk space metrics logged to Datadog"