Skip to content

Docs - Update disk sizes #38

Docs - Update disk sizes

Docs - Update disk sizes #38

name: Docs - Update disk sizes
# Triggers after a successful sync-from-scratch run (full or minimal node).
# Downloads the disk-usage artifacts, updates docs/site/src/data/disk-sizes.json,
# and opens (or updates) a draft PR against the measured run's branch.
on:
# zizmor: ignore[dangerous-triggers] no checkout of triggering run's head; BASE_BRANCH is pinned to release/3.4 for workflow_run events
workflow_run:
workflows:
- "QA - Sync from scratch"
- "QA - Sync from scratch (minimal node)"
types:
- completed
branches:
- main
- release/3.*
workflow_dispatch:
inputs:
run_id:
description: "Workflow run ID to pull disk-usage artifacts from"
required: true
base_branch:
description: "Base branch to update"
required: true
default: "release/3.4"
prune_mode:
description: "Prune mode measured in that run"
required: true
default: "full"
type: choice
options:
- full
- minimal
permissions:
contents: write
pull-requests: write
actions: read
concurrency:
group: update-disk-sizes-${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || 'manual' }}
cancel-in-progress: false
jobs:
update-disk-sizes:
# For workflow_run: only proceed on success.
# For workflow_dispatch: always proceed.
if: >
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Determine prune mode and source run ID
id: determine
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_PRUNE_MODE: ${{ github.event.inputs.prune_mode }}
INPUT_RUN_ID: ${{ github.event.inputs.run_id }}
INPUT_BASE_BRANCH: ${{ github.event.inputs.base_branch }}
WORKFLOW_RUN_NAME: ${{ github.event.workflow_run.name }}
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
case "$INPUT_PRUNE_MODE" in
full|minimal) ;;
*)
echo "::error::Invalid prune mode: $INPUT_PRUNE_MODE"
exit 1
;;
esac
if ! [[ "$INPUT_RUN_ID" =~ ^[0-9]+$ ]]; then
echo "::error::Invalid run_id: must be numeric"
exit 1
fi
if ! [[ "$INPUT_BASE_BRANCH" =~ ^[A-Za-z0-9._/-]+$ ]]; then
echo "::error::Invalid base_branch: allowed chars are [A-Za-z0-9._/-]"
exit 1
fi
printf 'prune_mode=%s\n' "$INPUT_PRUNE_MODE" >> "$GITHUB_OUTPUT"
printf 'source_run_id=%s\n' "$INPUT_RUN_ID" >> "$GITHUB_OUTPUT"
printf 'base_branch=%s\n' "$INPUT_BASE_BRANCH" >> "$GITHUB_OUTPUT"
elif [[ "$WORKFLOW_RUN_NAME" == *"minimal"* ]]; then
printf 'prune_mode=minimal\n' >> "$GITHUB_OUTPUT"
printf 'source_run_id=%s\n' "$WORKFLOW_RUN_ID" >> "$GITHUB_OUTPUT"
printf 'base_branch=release/3.4\n' >> "$GITHUB_OUTPUT"
else
printf 'prune_mode=full\n' >> "$GITHUB_OUTPUT"
printf 'source_run_id=%s\n' "$WORKFLOW_RUN_ID" >> "$GITHUB_OUTPUT"
printf 'base_branch=release/3.4\n' >> "$GITHUB_OUTPUT"
fi
- name: Generate GitHub App token
id: app_token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 ## v3.2.0
with:
client-id: ${{ vars.RELEASE_BOT_APP_ID }}
private-key: ${{ secrets.RELEASE_BOT_APP_KEY }}
repositories: "erigon"
- name: Checkout base branch
uses: actions/checkout@v6
with:
ref: ${{ steps.determine.outputs.base_branch }}
token: ${{ steps.app_token.outputs.token }}
persist-credentials: true
- name: Prepare update branch
env:
BASE_BRANCH: ${{ steps.determine.outputs.base_branch }}
run: |
set -euo pipefail
BRANCH="docs/auto/disk-sizes-${BASE_BRANCH//\//-}"
if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
git fetch origin "$BRANCH:refs/remotes/origin/$BRANCH"
git checkout -B "$BRANCH" "refs/remotes/origin/$BRANCH"
else
git checkout -B "$BRANCH"
fi
- name: Download disk usage artifacts
uses: actions/download-artifact@v8
with:
run-id: ${{ steps.determine.outputs.source_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
pattern: disk-usage-*
path: ./artifacts
merge-multiple: true
- name: List downloaded artifacts
run: ls -lh ./artifacts/ 2>/dev/null || echo "No artifacts found"
- name: Verify artifacts are present
env:
SOURCE_RUN_ID: ${{ steps.determine.outputs.source_run_id }}
run: |
set -euo pipefail
if [ -z "$(ls -A ./artifacts 2>/dev/null)" ]; then
echo "::error::No disk-usage artifacts found in run $SOURCE_RUN_ID — aborting"
exit 1
fi
echo "Found $(ls ./artifacts | wc -l) artifact file(s)"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Update disk-sizes.json
env:
PRUNE_MODE: ${{ steps.determine.outputs.prune_mode }}
run: |
set -euo pipefail
python3 docs/site/scripts/update-disk-sizes.py \
./artifacts \
docs/site/src/data/disk-sizes.json \
"$PRUNE_MODE"
- name: Check for changes
id: diff
run: |
set -euo pipefail
if git diff --quiet docs/site/src/data/disk-sizes.json; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes to disk-sizes.json"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
git diff docs/site/src/data/disk-sizes.json
fi
- name: Configure git
if: steps.diff.outputs.changed == 'true'
env:
RUN_ID: ${{ github.run_id }}
run: |
set -euo pipefail
git config user.name "github-workflow-update-disk-sizes-run-${RUN_ID}"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit and push to update branch
if: steps.diff.outputs.changed == 'true'
env:
BASE_BRANCH: ${{ steps.determine.outputs.base_branch }}
run: |
set -euo pipefail
BRANCH="docs/auto/disk-sizes-${BASE_BRANCH//\//-}"
git add docs/site/src/data/disk-sizes.json
git commit -m "chore(docs): auto-update measured disk sizes [$(date +%Y-%m-%d)]"
git push origin "$BRANCH"
- name: Create or update draft PR
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
BASE_BRANCH: ${{ steps.determine.outputs.base_branch }}
run: |
set -euo pipefail
BRANCH="docs/auto/disk-sizes-${BASE_BRANCH//\//-}"
TODAY=$(date +%Y-%m-%d)
EXISTING=$(gh pr list --head "$BRANCH" --base "$BASE_BRANCH" --state open --json number --jq '.[0].number // empty' 2>/dev/null)
if [ -z "$EXISTING" ]; then
gh pr create \
--draft \
--head "$BRANCH" \
--base "$BASE_BRANCH" \
--title "docs: auto-update disk size measurements ($TODAY)" \
--body "$(cat <<'EOF'
## Automated disk size update
Opened automatically by the **Docs - Update disk sizes** CI workflow after a successful sync-from-scratch run.
### What changed
`docs/site/src/data/disk-sizes.json` — `full` and/or `minimal` mode disk usage updated from the latest CI measurement. The hardware requirements page consumes this file directly, so merging this PR is all that's needed.
### What this does NOT update
- **Archive** mode: requires manual measurement from always-on snapshot machines.
- **Recommended disk size** column: intentionally static (should remain a comfortable buffer above current usage).
### Before merging
- Values should show gradual growth vs. the previous entry — a sudden drop or doubling is suspect.
- If both `full` and `minimal` runs completed today, both sets of chains are included (the branch is updated by each run).
🤖 Auto-generated by [update-disk-sizes.yml](/.github/workflows/update-disk-sizes.yml)
EOF
)"
echo "Created new draft PR for branch $BRANCH"
else
echo "PR #$EXISTING already open for branch $BRANCH — branch updated"
fi