Docs - Update disk sizes #561
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs - Update disk sizes | |
| # Triggers after a successful sync-from-scratch run (full or minimal node). | |
| # Archive sizes are not handled here: they are read manually from the Grafana | |
| # dashboard and committed by hand in a dedicated monthly PR. | |
| # Downloads the disk-usage artifacts, updates docs/site/src/data/disk-sizes.json, | |
| # and opens (or updates) a draft PR against a pinned base branch (release/3.6). | |
| on: | |
| # zizmor: ignore[dangerous-triggers] no checkout of triggering run's head; BASE_BRANCH is pinned to release/3.6 for workflow_run events | |
| workflow_run: | |
| workflows: | |
| - "QA - Sync from scratch (minimal node)" | |
| - "QA - Sync from scratch (full 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 | |
| # Official docs branch — bump at each release cutover (e.g. 3.5 → 3.6). | |
| default: "release/3.6" | |
| 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" | |
| else | |
| # Map the producing workflow → the mode it measured: | |
| # "QA - Sync from scratch (minimal node)" → minimal | |
| # "QA - Sync from scratch (full node)" → full | |
| if [[ "$WORKFLOW_RUN_NAME" == *"minimal"* ]]; then | |
| MODE=minimal | |
| elif [[ "$WORKFLOW_RUN_NAME" == *"full node"* ]]; then | |
| MODE=full | |
| else | |
| echo "::error::Unexpected producing workflow: $WORKFLOW_RUN_NAME" | |
| exit 1 | |
| fi | |
| printf 'prune_mode=%s\n' "$MODE" >> "$GITHUB_OUTPUT" | |
| printf 'source_run_id=%s\n' "$WORKFLOW_RUN_ID" >> "$GITHUB_OUTPUT" | |
| # Official docs branch — bump at each release cutover (e.g. 3.5 → 3.6). | |
| printf 'base_branch=release/3.6\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" | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - name: Checkout base branch | |
| uses: actions/checkout@v7 | |
| 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@v7 | |
| 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" | |
| # Project the updated JSON onto the static markers in the | |
| # hardware-requirements page (see README "Disk size data flow"). | |
| python3 docs/site/scripts/render-disk-sizes.py | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| set -euo pipefail | |
| TARGETS="docs/site/src/data/disk-sizes.json docs/site/docs/get-started/hardware-requirements.mdx" | |
| if git diff --quiet -- $TARGETS; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "No changes to disk sizes" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| git diff -- $TARGETS | |
| 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 docs/site/docs/get-started/hardware-requirements.mdx | |
| 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. `docs/site/docs/get-started/hardware-requirements.mdx` is regenerated from it (static values between MDX markers), so both files are included and 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 |