Cleanup Plan Docs #36
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: Cleanup Plan Docs | |
| on: | |
| schedule: | |
| - cron: '0 23 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| steps: | |
| - name: Checkout staging | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: staging | |
| token: ${{ github.token }} | |
| - name: Configure Git User | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check for plan files | |
| id: check | |
| run: | | |
| PLAN_FILES=$(find . -maxdepth 1 -name "PLAN-*.md" 2>/dev/null || true) | |
| DOCS_FILES="" | |
| if [ -d "./docs/plans" ]; then | |
| DOCS_FILES=$(find ./docs/plans -maxdepth 1 -name "*.md" 2>/dev/null || true) | |
| fi | |
| if [ -z "$PLAN_FILES" ] && [ -z "$DOCS_FILES" ]; then | |
| echo "found=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "found=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build PR body and remove plan files | |
| id: build_body | |
| if: steps.check.outputs.found == 'true' | |
| run: | | |
| TABLE="| Plan | Status |\n|------|--------|\n" | |
| scan_plans() { | |
| while IFS= read -r -d '' FILE; do | |
| TITLE=$(grep -m1 "^# " "$FILE" | sed 's/^# //') | |
| STATUS=$(grep -m1 "^Status:" "$FILE" | sed 's/^Status: *//' | tr -d '[:space:]') | |
| [ -z "$TITLE" ] && TITLE="$(basename "$FILE" .md)" | |
| [ -z "$STATUS" ] && STATUS="—" | |
| TABLE="${TABLE}| \`$(basename "$FILE")\` — ${TITLE} | ${STATUS} |\n" | |
| done | |
| } | |
| scan_plans < <(find . -maxdepth 1 -name "PLAN-*.md" -print0 2>/dev/null || true) | |
| if [ -d "./docs/plans" ]; then | |
| scan_plans < <(find ./docs/plans -maxdepth 1 -name "*.md" -print0 2>/dev/null || true) | |
| fi | |
| BODY="## Automated Plan Cleanup\n\nThis PR removes planning docs that were merged into \`staging\` during development.\n\n### Plans removed\n\n${TABLE}\n---\n\n> **Add highlights here** — anything worth preserving from these plans (key decisions, trade-offs, context for future contributors):\n\n" | |
| { | |
| echo 'pr_body<<CLEANUP_PR_BODY' | |
| printf '%b' "$BODY" | |
| echo 'CLEANUP_PR_BODY' | |
| } >> "$GITHUB_OUTPUT" | |
| git rm -f PLAN-*.md --ignore-unmatch | |
| if [ -d "./docs/plans" ]; then | |
| find ./docs/plans -maxdepth 1 -name "*.md" -exec git rm -f {} + 2>/dev/null || true | |
| fi | |
| - name: Create cleanup PR | |
| if: steps.check.outputs.found == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| branch: chore/cleanup-plan-docs | |
| base: staging | |
| commit-message: 'chore: NO-JIRA remove planning docs from staging' | |
| title: 'chore: NO-JIRA remove planning docs from staging' | |
| body: ${{ steps.build_body.outputs.pr_body }} | |
| delete-branch: true |