Skip to content

Conversation

@lmcdonough
Copy link
Contributor

Implements automated cleanup for PR preview environments. Triggers on pull_request closed event and calls backend reusable workflow.

lmcdonough and others added 4 commits November 6, 2025 19:46
Implement frontend PR preview overlay workflow that calls the reusable
deployment workflow from the backend repository.

**New File:**
- pr-preview-frontend.yml: Frontend PR overlay workflow
  - Triggers on frontend PR events (opened, synchronize, reopened)
  - Calls refactor-platform-rs reusable workflow
  - Builds frontend from PR branch, uses main-arm64 backend
  - Uses repository-level secrets (no pr-preview environment)
  - Passes all required secrets for deployment to RPi5

**Workflow Strategy:**
- repo_type: 'frontend' - builds frontend from PR, backend from main
- Automatic main-arm64 backend build if image doesn't exist
- Isolated PR environment with unique ports
- Full stack deployment (postgres, backend, frontend) on Neo/RPi5

**Secret Requirements:**
All secrets must be configured at repository level in frontend repo:
- RPi5 SSH/Tailscale connection details
- Database configuration (postgres user, password, db, schema)
- Third-party service credentials (TipTap, MailerSend)
- Frontend build configuration (backend service connection)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove all secret passing from frontend PR preview workflow. Secrets are
now automatically accessed from backend repo's pr-preview environment.

**Workflow Changes:**
- Remove entire `secrets:` section (45+ lines removed)
- No secrets needed in frontend repo for PR previews
- Workflow now only passes configuration inputs
- Uses backend repo's pr-preview environment automatically

**Documentation:**
- Add comprehensive PR preview runbook
- Links to backend runbook for complete details
- Add PR preview section to README
- Quick reference for developers

**Result:**
- Frontend repo needs ZERO PR preview secrets
- All secrets managed centrally in backend repo
- Single source of truth for configuration
- Simpler onboarding for new developers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add automatic cleanup workflow that triggers when frontend PRs are closed
or merged, calling the backend repo's reusable cleanup workflow.

**Frontend Caller (cleanup-pr-preview-frontend.yml):**
- Triggers on pull_request types: [closed]
- Calls backend repo's reusable cleanup workflow
- Passes only repo_type, pr_number, branch_name
- No secrets needed (uses backend pr-preview environment)

**What Gets Cleaned:**
- Docker containers (postgres, backend, frontend, migrator)
- Docker volumes (database data)
- Compose and environment files
- PR-specific images from RPi5 and GHCR

**What Gets Kept:**
- PostgreSQL base images (shared across PRs)
- main-arm64 images (for Docker layer caching)

**Benefits:**
- Automatic cleanup on PR close/merge
- Zero secrets required in frontend repo
- Prevents resource accumulation
- Follows same pattern as deploy workflow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
lmcdonough and others added 2 commits November 7, 2025 10:29
Add 'secrets: inherit' to pass GITHUB_TOKEN to the reusable workflow in
the backend repository. This is required when calling workflows across
repository boundaries.

The reusable workflow (in refactor-platform-rs) uses its own pr-preview
environment for all secrets, but needs the GITHUB_TOKEN from the calling
repository for authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…TODO

Changes:
1. Add TODO comment to update workflow reference to @main once backend PR #201 merges
2. Clarify that environment resolution uses backend repo's pr-preview environment
3. Add cleanup workflow to paths-ignore for consistency with backend

The frontend workflow now correctly documents that when calling the backend's
reusable workflow, the 'environment: pr-preview' references in that workflow
resolve to the BACKEND repo's environment, not the frontend's. This allows
centralizing all secrets in the backend repo's pr-preview environment.

The workflow inherits the fix from backend PR #201 (removal of problematic
'if: needs.build-arm64-image.result == success' condition) and will deploy
the full stack (backend + frontend + postgres) to neo when frontend PRs are
opened or updated.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This empty commit tests the frontend PR preview workflow to verify:
- Secrets are now accessible from backend repo's pr-preview environment
- Frontend lint and test jobs succeed
- Full stack deploys to neo (postgres + backend + frontend)
- PR comment posts with access URLs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Before merge: The docker-compose.pr-preview.yaml file only exists on the
backend PR branch (190-add-a-staging-environment...), not on main yet.
To allow frontend PR testing now, temporarily use the backend PR branch.

After merge: Both the workflow reference (@main) and backend_branch ('main')
should be updated back to stable references.

Changes:
- backend_branch: Use backend PR branch temporarily (has compose file)
- Updated TODO comments to be more specific about post-merge changes

This allows frontend workflow to succeed both before and after backend
PR #201 merges, following the same paradigm as backend workflow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Create GitHub Actions Workflows for Preview Environments on Pull Requests

2 participants