Feature/add symlink and sql flows#5
Draft
leglesslizard wants to merge 42 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an “Atomic Deploy” flow for WordPress deployments that can (a) run SQL migrations against a copied table prefix and then switch wp-config.php to the new prefix, and (b) atomically re-point plugin/theme symlinks to a release directory for fast rollbacks. This is implemented via new reusable workflow(s), a composite action that runs the remote swap script over SSH, and migration script templates, with README documentation updates.
Changes:
- Added
templates/migrations/swap.sh+templates/migrations/migrate.shto support prefix-copy migrations and symlink swapping during deploys. - Added
actions/swap-and-migratecomposite action and.github/workflows/atomic-deploy.yamlreusable workflow to run the remote deploy step and send notifications. - Expanded
README.mddocumentation for Atomic Deploy, rsync/FTP deploys, and templates.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
templates/migrations/swap.sh |
Remote deploy script: preflight, migration/prefix-swap, symlink swap, and release pruning logic. |
templates/migrations/migrate.sh |
Migration runner that applies pending SQL files and records them in a tracking table. |
actions/swap-and-migrate/action.yml |
Composite action that SSHes to the server to run swap.sh, then emails on failure based on exit codes. |
.github/workflows/atomic-deploy.yaml |
Reusable workflow wiring SSH setup + swap-and-migrate action with SMTP/notification secrets. |
README.md |
Documents the new Atomic Deploy flow and updates other workflow/action documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+78
to
+79
| CURRENT_PREFIX=$(wp config get table_prefix --path="$WP_ROOT") | ||
| LIVE_MIGRATIONS_TABLE="${CURRENT_PREFIX}${REPO_SLUG}_migrations" |
Comment on lines
+100
to
+107
| for COMPONENT in "${COMPONENTS[@]}"; do | ||
| NAME="${COMPONENT##*:}" | ||
| RELEASE_PATH="$NEW_RELEASE_DIR/$NAME" | ||
| if [ ! -d "$RELEASE_PATH" ]; then | ||
| echo "ERROR: $RELEASE_PATH not found — did the rsync job for $NAME complete?" >&2 | ||
| exit 1 | ||
| fi | ||
| done |
Comment on lines
+121
to
+123
| # Exit code 2: failed after live changes began — site is in maintenance mode, | ||
| # wp-config.php or symlinks may be in a partially-updated state. | ||
| - name: Send urgent notification — site in maintenance mode |
| # site is running on the previous version. | ||
| - name: Send failure notification — site recovered | ||
| if: steps.swap.outcome == 'failure' && steps.swap.outputs.ssh_exit == '1' && inputs.smtp-server != '' && inputs.smtp-username != '' && inputs.smtp-password != '' && inputs.notify-email != '' | ||
| uses: dawidd6/action-send-mail@v3 |
Comment on lines
+9
to
+13
| Deploys components to a release directory keyed by the git commit SHA, then atomically swaps them into place and runs any pending database migrations. When migrations are pending, the database work and component swap are performed inside a maintenance window. When there are no pending migrations, components are swapped with no downtime. Supports rollback by resyncing the prior release back to the live directories; when migrations ran, the old prefix tables are dropped during deployment, so a full rollback requires restoring from the pre-deploy backup. | ||
|
|
||
| **How it works:** | ||
|
|
||
| Rsync jobs deploy each component to a release directory keyed by the commit SHA. Once all jobs complete, the `atomic_deploy` job SSH's in and runs `swap.sh`, which: |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When merging in we'll need the following to get notifications to work: