Skip to content

Cleanup: PR Preview Documentation #362

Cleanup: PR Preview Documentation

Cleanup: PR Preview Documentation #362

# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: "Cleanup: PR Preview Documentation"
on:
schedule:
# Run every night at 11pm EST (4am UTC during EST, 3am UTC during EDT)
# Using 4am UTC to be safe during EST (Nov-Mar)
- cron: '0 4 * * *'
workflow_dispatch:
inputs:
dry-run:
description: 'Run in dry-run mode (preview only, no changes)'
required: false
default: false
type: boolean
permissions:
contents: write # Required to push changes to gh-pages branch
pull-requests: write # Required to retire sticky preview comments
jobs:
cleanup:
name: Clean up stale PR preview folders
runs-on: ubuntu-latest
# Must match every job that writes to gh-pages.
concurrency:
group: cuda-python-gh-pages-publish
queue: max
cancel-in-progress: false
# Only run for NVIDIA org to prevent forks from running this
if: github.repository_owner == 'NVIDIA'
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
with:
# The cleanup script fetches gh-pages explicitly; source history
# and unrelated branches aren't needed for the script checkout.
fetch-depth: 1
filter: blob:none
- name: Configure git identity
run: |
git config --global user.name "cuda-python-bot"
git config --global user.email "cuda-python-bot@users.noreply.github.com"
- name: Run PR preview cleanup script
id: cleanup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAGES_PUBLISH_LOCK: cuda-python-gh-pages-publish
run: |
if [[ "${{ inputs.dry-run }}" == "true" ]]; then
echo "Running in dry-run mode (preview only)"
./ci/cleanup-pr-previews --dry-run
else
echo "Running cleanup with push to gh-pages"
./ci/cleanup-pr-previews --push
fi
- name: Summary
if: always()
run: |
echo "### PR Preview Cleanup Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ steps.cleanup.outcome }}" != "success" ]]; then
echo "❌ Cleanup failed; no successful update was confirmed" >> $GITHUB_STEP_SUMMARY
elif [[ "${{ inputs.dry-run }}" == "true" ]]; then
echo "✅ Dry-run completed successfully" >> $GITHUB_STEP_SUMMARY
echo "No changes were made to the gh-pages branch or PR comments" >> $GITHUB_STEP_SUMMARY
else
echo "✅ Cleanup completed; gh-pages is up to date" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY