Skip to content

Add reusable deploy file for new projects - #52

Merged
itineris-milos merged 25 commits into
mainfrom
add-blocktheme-deployment-file
Aug 13, 2026
Merged

Add reusable deploy file for new projects#52
itineris-milos merged 25 commits into
mainfrom
add-blocktheme-deployment-file

Conversation

@itineris-milos

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread .github/workflows/deploy-blocktheme.yml Outdated
Comment thread .github/workflows/deploy-blocktheme.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
@codepuncher
codepuncher marked this pull request as draft May 7, 2026 10:17
@itineris-milos
itineris-milos marked this pull request as ready for review May 7, 2026 10:31
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
@codepuncher
codepuncher force-pushed the add-blocktheme-deployment-file branch from 0c73367 to d547ab9 Compare June 18, 2026 08:49
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.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

Adds a new reusable GitHub Actions workflow intended to deploy a WordPress site to Kinsta over SSH (with Tailscale), including build steps and post-deploy smoke checks. This lives in the central .github repo so other projects can call it via workflow_call.

Changes:

  • Introduces a reusable deploy-wp.yml workflow that installs dependencies, builds the theme, and rsyncs a release to a remote host.
  • Adds remote release management (uploads/.env symlinks, promote release, rollback on failure, cleanup old releases).
  • Adds optional smoke testing (with/without basic auth) and WP language pack installation/purging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/deploy-wp.yml
Comment thread .github/workflows/deploy-wp.yml
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
itineris-milos and others added 15 commits August 13, 2026 11:53
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds a guarded step that runs `wp core install` only when the site
isn't installed yet, so brand-new sites don't fail at the language
install step. No-op for every already-installed site using this
reusable workflow.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
itineris-milos and others added 6 commits August 13, 2026 11:53
Replaces the wp core install bootstrap with a lighter guard: check
wp core is-installed once, then skip language pack install, cache
purge, and plugin/theme language install when it isn't. Avoids
storing WP admin credentials, and is a no-op for every site that's
already live.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…l sites

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add --skip-plugins --skip-themes to every wp-cli invocation so deploy
steps don't fail on plugin/theme fatals during bootstrap.

Symlink ~/deploy/shared/wordfence-waf.php into each release so the
Wordfence WAF bootstrap persists across deploys (touch guards against a
dangling symlink on first deploy).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wordfence doesn't support symlinks.
@itineris-milos
itineris-milos force-pushed the add-blocktheme-deployment-file branch from e4fdaca to 6781961 Compare August 13, 2026 09:54
… quoting

- rm the release's wp-content/uploads before ln -sfn: a symlink cannot
  replace a real directory (e.g. a committed uploads/.gitkeep)
- Skip the rollback relink when there is no previous release (first
  deploy) but still remove the failed release directory
- Quote WP_LANG in remote wp-cli commands
- Rename the Wordfence step (it copies now) and skip when the shared
  file does not exist yet (brand-new sites)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@itineris-milos

itineris-milos commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Update: rebased, review addressed, OPcache purge added

Rebased onto main — all 21 commits replayed and re-signed (e4fdaca6781961), then three new commits:

Commit What
8d37bd4 Review fixes: guard uploads symlink against a real directory, skip rollback relink on first deploys (but still clean up the failed release), quote WP_LANG, rename the Wordfence step to Copy + skip when the shared file doesn't exist yet
23beeca Reset OPcache after promoting the release — same architecture as trellis-deploy.yml@0.9 (org secrets via secrets: inherit, X-Opcache-Purge header, SHA-256 fingerprint verified server-side by the itineris-opcache-purge mu-plugin). Fail-safe: warns, never fails a deploy; skips silently if the secret is absent. Sends basic auth when the site is protected
96a4861 Unique release dir per attempt (sha + run_id + run_attempt): keying on the sha alone reused — and on a failed re-run of the live commit, deleted — the directory production was serving from

(An earlier commit sharing wflogs across releases was dropped — Lee already solved the Wordfence WAF issue with the cp approach; the log folder was never the problem.)

Copilot review verdicts (inline replies on each thread): accepted the uploads-symlink guard, first-deploy rollback guard, WP_LANG quoting, and the release-dir-reuse fix; declined the workflow_call.secrets declaration (all callers use secrets: inherit — verified) and the auto-create-.deployignore suggestion (failing loudly beats silently deploying node_modules; the file is guaranteed by WordPressStarter).

⚠️ Reminder: callers pin @add-blocktheme-deployment-file, so these changes are live on the next deploy of any hybrid project. Everything is fail-safe by design, but test on a staging deploy (momentumcharity) before merge + tag.

Per-site follow-ups (not this PR): each hybrid project needs the itineris-opcache-purge mu-plugin + the OPCACHE_PURGE_TOKEN_HASH define before the purge confirms — until then the step logs a warning and moves on.

🤖 Generated with Claude Code

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 1 out of 1 changed files in this pull request and generated 1 comment.

Suppressed comments (3)

.github/workflows/deploy-wp.yml:191

  • On a first Kinsta deployment, ~/public is a real web-root directory. ln -sfn TARGET ~/public does not replace that directory; it creates a link inside it, so the web root is never promoted. Remove only an empty non-symlink directory first (and fail safely when migration is required) before creating the release symlink.
        run: ssh ${{ inputs.SSH_USER }}@${{ inputs.SSH_HOST }} -p ${{ vars.SSH_PORT }} 'ln -sfn ~/deploy/releases/${{ github.sha }} ~/public'

.github/workflows/deploy-wp.yml:222

  • This failure handler is evaluated before the cache purge, plugin/theme language installation, and cleanup steps. A failure in any of those later steps therefore leaves the new release promoted (and potentially partially modified) while the workflow reports failure. Place the rollback handler after all fallible post-promotion steps, or explicitly make non-critical post-deployment tasks non-failing.
      - name: Rollback deployment on failure
        if: failure()

.github/workflows/deploy-wp.yml:196

  • The secret is interpolated directly into shell syntax, so a valid basic-auth password containing a double quote, backtick, or command-substitution characters can break or alter this test. Pass the secret through the step environment and test the environment variable instead.
          if [ -n "${{ secrets.BASIC_AUTH_PASSWORD }}" ]; then

Comment thread .github/workflows/deploy-wp.yml Outdated
itineris-milos and others added 2 commits August 13, 2026 12:43
Atomic deploys leave OPcache saturated with stale release paths, forcing
PHP to recompile every script until entries expire. After promoting the
new release, request the site with the X-Opcache-Purge token so the
itineris-opcache-purge mu-plugin resets OPcache. Fail-safe: warns but
never fails the deploy; skips silently when the org secret is absent.
Sends basic auth when the site is protected, mirroring the smoke tests.

Same architecture as trellis-deploy.yml: the raw token is compared
server-side against the committed SHA-256 fingerprint, so it never
lives on the server.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Keying release directories on github.sha alone reuses the directory when
the same commit is redeployed (workflow_dispatch or a re-run). If that
release is currently live, rsync mutates production in place - and on a
failed re-run the rollback step relinks ~/public to that same directory
and then deletes it, taking the site down.

RELEASE_ID = sha + run_id + run_attempt is unique per attempt, so a
redeploy always builds alongside the live release and rollback always
has a distinct directory to remove.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@itineris-milos
itineris-milos force-pushed the add-blocktheme-deployment-file branch from 6981720 to 96a4861 Compare August 13, 2026 10:46
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml Outdated
Comment thread .github/workflows/deploy-wp.yml
Comment thread .github/workflows/deploy-wp.yml Outdated
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@itineris-milos
itineris-milos merged commit 9bf980b into main Aug 13, 2026
2 checks passed
@itineris-milos
itineris-milos deleted the add-blocktheme-deployment-file branch August 13, 2026 11:51
@codepuncher
codepuncher restored the add-blocktheme-deployment-file branch August 13, 2026 12:20
@codepuncher
codepuncher deleted the add-blocktheme-deployment-file branch August 13, 2026 12:29
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.

3 participants