-
Notifications
You must be signed in to change notification settings - Fork 2
190 add a staging environment for previewing and testing ahead of a new deployment #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lmcdonough
wants to merge
55
commits into
main
Choose a base branch
from
190-add-a-staging-environment-for-previewing-and-testing-ahead-of-a-new-deployment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
…ployment - Update workflow dispatch comments for clarity - Remove unused frontend branch input from workflow - Enhance concurrency comments for better understanding - Adjust permissions for GitHub Container Registry - Improve deployment context calculations and logging - Update Docker Compose configuration for better readability and organization - Ensure health checks and environment variables are clearly defined - Streamline deployment steps and comments for clarity
- Implement multi-layer cache fallback chain (PR → branch → main) - Scope cache writes to PR-specific namespace for better isolation - Expected improvements: - First PR build: 6-9 min (down from 10-15 min) - Subsequent PR builds: 2-5 min (down from 10-15 min) - Uses scoped GitHub Actions cache to reuse compiled dependencies - Maintains conditional force rebuild capability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Builds ARM64 image from main branch daily at 2 AM UTC - Runs after main branch changes to dependencies or code - Reuses previous cache to minimize rebuild time (2-4 min typical) - Writes to scope=main for PR preview workflows to utilize - Expected impact: Reduces first PR build from 20-25 min to 6-9 min Benefits: - 60-70% faster first-time PR preview builds - Automatic cache refresh keeps dependencies up-to-date - Minimal GitHub Actions cost (~100-150 min/month) - Net savings: 150-200 min/month for active development 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ng strategies, and deployment steps for ARM64 images on RPi5
… parallel execution of Docker builds
…code quality before ARM64 builds
…s and optimizing variable usage for clarity and maintainability.
…ing cache keys, and enhancing deployment steps for RPi5.
…on steps The dtolnay/rust-toolchain action requires an explicit 'toolchain' input parameter. Added 'toolchain: stable' to all Rust toolchain installation steps in both deploy-pr-preview.yml and build-test-push.yml workflows to resolve the "'toolchain' is a required input" error that was causing lint jobs to fail. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixes three critical issues in the deploy-to-rpi5 job:
1. **Heredoc variable expansion**: Changed from quoted heredoc ('ENDSSH')
to passing variables via SSH environment. The quoted heredoc prevented
GitHub Actions variables from being expanded, causing all variables to
be empty on the remote server.
2. **PROJECT_NAME availability**: Now explicitly passed as an environment
variable to the SSH session. Previously undefined in the remote context,
causing docker compose commands to fail.
3. **Error handling**: Changed from 'set -e' to 'set -eo pipefail' to
properly catch errors in piped commands (like docker login). The previous
setting would not catch failures in the left side of pipes.
Technical changes:
- Pass all variables via SSH command prefix instead of heredoc exports
- Use ${VAR} syntax throughout heredoc for consistency
- Add GITHUB_TOKEN, GITHUB_ACTOR, RPI5_USERNAME, and SERVICE_STARTUP_WAIT_SECONDS
to SSH environment variables
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace manual Default implementation with derive attribute as suggested by clippy::derivable_impls lint. The manual implementation was simply returning Self::InProgress, which can be expressed more idiomatically using #[derive(Default)] with #[default] on the InProgress variant. Changes: - Add Default to derive macro for Status enum - Add #[default] attribute to InProgress variant - Remove manual impl std::default::Default for Status This resolves the clippy error that was failing the Lint & Format job in CI with -D warnings enabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This empty commit tests the fixed PR preview workflow to verify: - deploy-to-rpi5 job now runs (no longer skipped) - 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>
Change all secrets from required: true to required: false in the reusable workflow. This is necessary because: 1. Secrets are resolved from the pr-preview environment at job execution time 2. When calling from another repo (frontend → backend), GitHub requires secrets marked as required: true to be passed from the caller 3. The frontend repo doesn't have these secrets - they're centralized in the backend repo's pr-preview environment 4. Setting required: false allows cross-repo calls to succeed while secrets are still available from the environment when jobs execute This maintains the centralized secrets approach while enabling both same-repo (backend PR) and cross-repo (frontend PR) workflow calls to succeed. Fixes: Frontend workflow error "Secret X is required, but not provided" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Root cause: The build-arm64-image job uses 'if: always() && ...' which
causes it to have a non-standard result status. When deploy-to-rpi5
depends on it with just 'needs: build-arm64-image', the default behavior
is to only run if the needed job has a simple 'success' status. Jobs using
always() don't match this, so the deploy job was being skipped.
Solution: Add the same always() pattern to deploy-to-rpi5:
if: |
always() &&
!cancelled() &&
needs.build-arm64-image.result == 'success'
This explicitly checks the build result and runs whenever the build
succeeds, regardless of the build job's conditional execution pattern.
This is a minimal change that follows the existing pattern used for
build-arm64-image and ensures deploy always runs when build succeeds.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Root cause: The deploy job was checking out ref: main to get the
docker-compose.pr-preview.yaml file, but this file doesn't exist on main
yet - it only exists in the PR branch.
Solution: Change the checkout ref from hardcoded 'main' to use the
backend_branch output from build-arm64-image job:
ref: ${{ needs.build-arm64-image.outputs.backend_branch }}
This ensures:
- Backend PRs: Uses the PR branch (where compose file exists)
- Frontend PRs: Uses main branch (where compose file will exist after merge)
Minimal change that follows existing pattern of using job outputs.
Fixes: "scp: stat local backend-compose/docker-compose.pr-preview.yaml:
No such file or directory"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Root cause: The schema preparation step was missing two environment variables that docker-compose.pr-preview.yaml requires: - PR_FRONTEND_CONTAINER_PORT - FRONTEND_IMAGE This caused docker compose to fail with "invalid proto:" error because the variables defaulted to blank strings. Solution: Add the missing variables to the schema preparation environment file to match the deploy step's environment file. Both steps now have identical variable sets. Changes: - Line 817: Added FRONTEND_IMAGE from build outputs - Line 823: Added PR_FRONTEND_CONTAINER_PORT from ports outputs Minimal change following existing pattern. Frontend workflow already has these variables in its deploy step, so no changes needed there. Fixes: "The PR_FRONTEND_CONTAINER_PORT variable is not set" and "invalid proto:" errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Root cause: The backend service expects uppercase log level values (OFF, ERROR, WARN, INFO, DEBUG, TRACE) but the workflow was passing lowercase 'info', causing the backend to fail at startup with: error: invalid value 'info' for '--log-level-filter <LOG_LEVEL_FILTER>' Solution: Changed BACKEND_LOG_FILTER_LEVEL from 'info' to 'INFO' in both environment file creation locations (schema prep and deploy steps). Changes: - Line 832: info -> INFO (schema preparation) - Line 951: info -> INFO (deployment) Minimal change - only case correction, no logic changes. Fixes: Backend startup failure due to invalid log level argument 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🚀 PR Preview Environment Deployed!🔗 Access URLs
📊 Environment Details
🔐 Access Requirements
🧪 Testing# Health check
curl http://neo.rove-barbel.ts.net:4201/health
# API test
curl http://neo.rove-barbel.ts.net:4201/api/v1/users🧹 CleanupEnvironment auto-cleaned when PR closes/merges Deployed: 2025-11-07T18:20:56.092Z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚀 Add Automated PR Preview Deployments
Implements isolated staging environments for every pull request.
What This Does
Architecture
4000 + PR_NUMBER5432 + PR_NUMBERpr-{number}(complete isolation)ghcr.io/owner/repo:pr-{number}Files Added
.github/workflows/deploy-pr-preview.yml- Deployment automation.github/workflows/cleanup-pr-preview.yml- Cleanup automationdocker-compose.pr-preview.yaml- Multi-tenant templatedocs/PR-PREVIEW.md- Usage documentationAccess