Skip to content
prod e051e98
Browse

2 · Server sync — capture server changes

Objective — capture changes made on the server (admin-panel uploads, installer output, config) back into git before the next deploy silently wipes them — and do it without ever committing secrets.

A deployed app has two sources of truth that can drift apart: git (your code) and the server (files written after deploy — a logo uploaded through the admin panel, files the web installer generated, an admin config change). Your deploy pipeline clears and replaces server directories on every release — so anything the server wrote that git doesn’t know about gets erased on the next deploy.

Server sync closes that gap: it pulls those server-side changes back into git first, so the next deploy preserves them instead of destroying them.

flowchart LR
A["Server writes file<br/>upload · installer · config"] --> B["Capture into git<br/>commit on production"]
B --> C["Review file list<br/>no secrets"]
C --> D["Merge to develop<br/>safe to deploy"]

The risk runs the other way too: server files can include .env, private keys, or logs with personal data. Capturing those into git would leak secrets — so every sync is review-first, never auto-merge.

For the command-only card, see the Server sync capture runbook.

Not every server change needs syncing. Match what changed against the table so you only capture real, durable files — and never sweep secrets in by accident.

  1. Match the change against the capture table.

    Change typeExampleCapture?
    Admin-panel uploadsLogo, favicon, images✅ Yes
    Web installer outputGenerated files, storage/installed✅ Yes
    Composer install on serverPackage installed on the server✅ Yes
    Admin-panel configSMTP, payment keys⚠️ Maybe — .env.example updates only
    • ✅ You’ve confirmed the change is a real, durable file worth keeping in git.

Two ways to capture: the GitHub Action does it for you (preferred), or you do it by hand over SSH. Either way, the server’s new files land as a commit on the production branch.

  1. Preferred — trigger the ServerSync GitHub Action. From the repository’s Actions tab, run the capture workflow (e.g. capture-production.yml) for the right environment. It SSHes in, captures the shared directories, and commits to production for you.

    • ✅ The workflow run finishes and a capture commit appears on production.
  2. Manual fallback — capture over SSH, screening for secrets first. Use this only if the Action isn’t available.

    Terminal window
    ssh [SSH_PRODUCTION_ALIAS]
    cd [DEPLOY_PATH]
    git status
    # Expected: a list of changed files. If .env, *.key, *.pem, or credentials appear, DO NOT stage them.
    git add .
    git commit -m "🔄 ⬛ T5 ServerSync-Upload: Capture [description]"
    git push origin production
    # Expected: the server-side files are committed and pushed on production
    • ✅ The captured files are committed on production and no secret file is staged.

This is the human gate. A sync commit can include deletions caused by config drift, not just safe additions — so a person reads the file list before it merges anywhere.

  1. Pull the capture locally and inspect the file list.

    Terminal window
    git checkout production && git pull origin production
    git log --oneline -3
    git show --stat HEAD
    # Expected: the capture commit, and a file list of exactly what changed
    • ✅ Every captured file is an intentional ADDED/MODIFIED asset — no surprise DELETED files, no secrets.

If you see DELETED files you didn’t expect, that’s drift between the deploy config’s clear_paths and the sync workflow’s GIT_ONLY_PATHS — fix the symmetry before trusting another sync, rather than committing the deletions.

Once reviewed, fold the capture into develop so your everyday branch carries the server’s truth and the next ship doesn’t reintroduce the drift.

  1. Merge production into develop and push.

    Terminal window
    git checkout develop && git merge production && git push origin develop
    # Expected: develop now contains the captured server files
    • develop carries the captured changes; you can resume normal development and ship when ready.

Do not mark this step done until every box below is checked.

  • 👤 Worth capturing — the change is a durable server file (upload / installer output / config), not noise.
  • 🤖 No secrets staged — no .env, *.key, *.pem, logs, or credentials in the commit.
  • 🤖 Committed on production — captured via the GitHub Action or manual SSH, with a T5 ServerSync message.
  • 👤 File list reviewed — inspected git show --stat; no unexpected DELETED files; not auto-merged.
  • 🤖 Merged to developproduction folded back into develop and pushed.