Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • A Ahad Mobile
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • holatech
  • Ahad Mobile
  • Merge requests
  • !79

feat(infra): add a staging env edit-and-redeploy command

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Khanh Pham requested to merge feat/staging-edit-env into develop Sep 25, 2026
  • Overview 0
  • Commits 4
  • Pipelines 1
  • Changes 1

Summary

infra/runtime/staging/edit-env.sh: one command to change the staging app env and redeploy it.

infra/runtime/staging/edit-env.sh                # open moanapay/staging/app-env in $EDITOR, save, confirm
infra/runtime/staging/edit-env.sh FILE           # replace the env with FILE
infra/runtime/staging/edit-env.sh --redeploy     # redeploy only
infra/runtime/staging/edit-env.sh --rollback-env # restore the previous env version and redeploy

Runs on the Mac (needs ssh moanapay-vps + authenticated glab).

  • Fetches the secret byte-exact into a 0700 temp dir, removed on exit; values never printed.
  • Validates: no NUL, only KEY=value/comment/blank lines, no duplicate keys.
  • Shows added / removed / changed / newly EMPTY key names, then asks y/N.
  • Refuses to push if the secret's VersionId changed while editing.
  • Redeploys by retrying the CI job behind the staging environment's last deployment (same job, lock and logs as a normal deploy), waits up to 20 min, then requires /health.
  • Any failure after the push prints the job URL and both recovery commands (--redeploy, --rollback-env). The CI trace is not printed.

Verification

  • shellcheck clean.
  • Live against staging LocalStack: no-change exit, diff + abort, invalid env rejected, rollback no-op, concurrent-change refusal, byte-exact fetch/push round trip (twice).
  • Stubbed: glab 502 after push, push failure, job success + failing /health → nonzero exit with recovery guidance.
  • Not exercised live: the job retry itself (it restarts staging).
  • Codex adversarial review: 3 rounds, did not formally converge. All findings fixed except one, rebutted: a backend-owned env schema is a separate be/ feature.

🤖 Generated with Claude Code

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: feat/staging-edit-env