Skip to content

Feature/add symlink and sql flows#5

Draft
leglesslizard wants to merge 42 commits into
mainfrom
feature/add-symlink-and-sql-flows
Draft

Feature/add symlink and sql flows#5
leglesslizard wants to merge 42 commits into
mainfrom
feature/add-symlink-and-sql-flows

Conversation

@leglesslizard

@leglesslizard leglesslizard commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

When merging in we'll need the following to get notifications to work:

  • Add SMTP_SERVER, SMTP_USERNAME, SMTP_PASSWORD at organisation level (used by the failure notification email)
  • NOTIFY_EMAIL is optional per-repo - defaults to #uptime_alerts if omitted (email is harcoded for now, I assume we'll want this to go to something@pie.co.de)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to support prefix-copy migrations and symlink swapping during deploys.
  • Added actions/swap-and-migrate composite action and .github/workflows/atomic-deploy.yaml reusable workflow to run the remote deploy step and send notifications.
  • Expanded README.md documentation 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 thread templates/migrations/swap.sh Outdated
Comment thread templates/migrations/swap.sh Outdated
Comment thread actions/swap-and-migrate/scripts/migrate.sh
Comment thread actions/swap-and-migrate/action.yml Outdated
Comment thread actions/swap-and-migrate/action.yml
Comment thread actions/swap-and-migrate/action.yml Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.

Comment thread actions/swap-and-migrate/action.yml Outdated
Comment thread .github/workflows/atomic-deploy.yaml
Comment thread templates/migrations/swap.sh Outdated
Comment thread templates/migrations/swap.sh
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
Comment thread README.md Outdated
@leglesslizard leglesslizard requested a review from Copilot June 30, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment thread templates/migrations/swap.sh Outdated
Comment thread templates/migrations/swap.sh Outdated
Comment thread README.md Outdated
Comment thread actions/swap-and-migrate/action.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread templates/migrations/migrate.sh Outdated
Comment thread actions/swap-and-migrate/action.yml Outdated
Comment thread actions/swap-and-migrate/action.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Comment thread actions/swap-and-migrate/action.yml Outdated
Comment thread actions/swap-and-migrate/scripts/migrate.sh Outdated
Comment thread actions/swap-and-migrate/scripts/swap.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 11 comments.

Comment thread .github/workflows/deploy.yaml
Comment thread .github/workflows/deploy.yaml
Comment thread .github/workflows/deploy.yaml
Comment thread .github/workflows/atomic-deploy.yaml
Comment thread .github/workflows/atomic-deploy.yaml
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 thread README.md
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>
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.

2 participants