Add GitHub Actions CI/CD pipeline with automated deployment - #2
Conversation
CI workflow: install Composer/Node deps, run migrations against a MySQL service, execute PHPUnit on PHP 7.2/7.3, and compile production assets. Deploy workflow: on successful CI on master (or manual dispatch), build a production bundle and release it over SSH with timestamped, symlink-based zero-downtime releases, migrations, config/route caching, and old-release pruning. Includes DEPLOYMENT.md documenting required secrets and server layout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tfc1nqw5KBG6fJdKbJhyc1
package:discover failed with 'Undefined index: name' because Laravel 5.6's PackageManifest can't read Composer 2's installed.json format; pin composer:v1. The assets build failed because node-sass 4.9.4 has no prebuilt binary for Node 14 and the source build errors; drop to Node 10 which has a prebuilt. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tfc1nqw5KBG6fJdKbJhyc1
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b46f58d7c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cd "$RELEASE" | ||
| php artisan migrate --force | ||
| php artisan config:cache | ||
| php artisan route:cache |
There was a problem hiding this comment.
Do not cache routes while closure routes remain
This repo still has the default closure route in routes/api.php:16; in Laravel 5.6, php artisan route:cache fails when any route is a Closure, and because this SSH script is running under set -euo pipefail, every production deploy will abort here before the current symlink is switched. Convert/remove the closure route or skip route caching until the route table is cacheable.
Useful? React with 👍 / 👎.
| - name: Checkout | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
Pin deploy checkout to the tested CI SHA
For workflow_run, GitHub documents GITHUB_SHA as the last commit on the default branch (https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_run), so this default checkout is not tied to github.event.workflow_run.head_sha. If a second push reaches master before an older CI run finishes, the older successful run can deploy the newer, unverified commit; set the checkout ref to the triggering run's head_sha for workflow-run deploys.
Useful? React with 👍 / 👎.
Address two review findings on the deploy workflow: - workflow_run checks out the default-branch tip, which can be a newer, unverified commit than the one CI validated. Pin the checkout ref to github.event.workflow_run.head_sha (falling back to github.sha for manual dispatch) so only the tested commit is deployed. - Laravel 5.6's route:cache aborts when any route uses a Closure (the default routes/api.php /user route does), which under set -euo pipefail would fail every deploy before the release symlink is switched. Fall back to route:clear so a non-cacheable route table can't break deploys. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tfc1nqw5KBG6fJdKbJhyc1
Summary
This PR introduces a complete GitHub Actions CI/CD pipeline for automated testing and production deployment. The pipeline consists of two workflows that ensure code quality before releasing to production.
Key Changes
CI Workflow (
.github/workflows/ci.yml): Runs on every push and pull requestDeploy Workflow (
.github/workflows/deploy.yml): Runs automatically after CI succeeds onmaster(or manually via workflow dispatch)Deployment Documentation (
DEPLOYMENT.md): Comprehensive guide coveringNotable Implementation Details
.envandstorage/) survives across deployments via symlinksset -euo pipefailin deployment scriptshttps://claude.ai/code/session_01Tfc1nqw5KBG6fJdKbJhyc1