Skip to content

Commit f4d0dfa

Browse files
Copilotleofang
andcommitted
Add scheduled workflow to clean up PR preview documentation
Co-authored-by: leofang <[email protected]>
1 parent 49bdbce commit f4d0dfa

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: "Cleanup: PR Preview Documentation"
6+
7+
on:
8+
schedule:
9+
# Run every night at 11pm EST (4am UTC during EST, 3am UTC during EDT)
10+
# Using 4am UTC to be safe during EST (Nov-Mar)
11+
- cron: '0 4 * * *'
12+
workflow_dispatch:
13+
inputs:
14+
dry-run:
15+
description: 'Run in dry-run mode (preview only, no changes)'
16+
required: false
17+
default: false
18+
type: boolean
19+
20+
permissions:
21+
contents: write # Required to push changes to gh-pages branch
22+
23+
jobs:
24+
cleanup:
25+
name: Clean up stale PR preview folders
26+
runs-on: ubuntu-latest
27+
# Only run for NVIDIA org to prevent forks from running this
28+
if: github.repository_owner == 'NVIDIA'
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
# Fetch all history and branches for worktree operations
34+
fetch-depth: 0
35+
36+
- name: Set up GitHub CLI
37+
run: |
38+
# GitHub CLI is pre-installed on ubuntu-latest
39+
gh --version
40+
41+
- name: Install jq
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y jq
45+
46+
- name: Configure git identity
47+
run: |
48+
git config --global user.name "github-actions[bot]"
49+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
- name: Run PR preview cleanup script
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
# Determine if we should run in dry-run mode
56+
if [[ "${{ inputs.dry-run }}" == "true" ]]; then
57+
echo "Running in dry-run mode (preview only)"
58+
./ci/cleanup-pr-previews --dry-run
59+
else
60+
echo "Running cleanup with push to gh-pages"
61+
./ci/cleanup-pr-previews --push
62+
fi
63+
64+
- name: Summary
65+
if: always()
66+
run: |
67+
echo "### PR Preview Cleanup Summary" >> $GITHUB_STEP_SUMMARY
68+
echo "" >> $GITHUB_STEP_SUMMARY
69+
if [[ "${{ inputs.dry-run }}" == "true" ]]; then
70+
echo "✅ Dry-run completed successfully" >> $GITHUB_STEP_SUMMARY
71+
echo "No changes were made to the gh-pages branch" >> $GITHUB_STEP_SUMMARY
72+
else
73+
echo "✅ Cleanup completed and changes pushed to gh-pages" >> $GITHUB_STEP_SUMMARY
74+
fi
75+
echo "" >> $GITHUB_STEP_SUMMARY
76+
echo "Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)