Skip to content

feat(secrets): add SOPS + age secrets management with stackctl.sh integration#491

Merged
wax911 merged 9 commits into
devfrom
chore/sops-age-secrets-setup
Jun 16, 2026
Merged

feat(secrets): add SOPS + age secrets management with stackctl.sh integration#491
wax911 merged 9 commits into
devfrom
chore/sops-age-secrets-setup

Conversation

@wax911

@wax911 wax911 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Adopt the service-local .env.enc SOPS+age pattern (matching ../../docker/) for encrypting secrets at rest in git, with just-in-time decryption at deploy time via stackctl.sh secrets.

Changes

File Change
.sops.yaml Replace secrets/ path regex with \.env$, use key_groupsage format with real public key
.gitignore Add !*.env.enc allowlist so encrypted files are tracked
stackctl.sh Add secrets subcommand: encrypt, decrypt, deploy, clean
docs/Managing Secrets.md Full rewrite for service-local .env.enc workflow
README.md Add secrets workflow reference; fix duplicate section numbering
stacks/README.md Add secrets deploy notes to doctor and stackctl sections
docs/proposals/Secrets Management Proposal.md Update Phase 1 status to ✅; fix stale secrets/ paths

New stackctl.sh secrets commands

./stackctl.sh secrets encrypt [service]   # .env → .env.enc
./stackctl.sh secrets decrypt [service]   # .env.enc → .env
./stackctl.sh secrets deploy [service]   # decrypt → render → deploy → shred
./stackctl.sh secrets clean               # shred all plaintext .env with .env.enc

Workflow

  1. cp service/.env.example service/.env → fill in real values
  2. ./stackctl.sh secrets encrypt service → commits .env.enc
  3. ./stackctl.sh secrets deploy service → decrypt, render, deploy, shred
  4. ./stackctl.sh secrets clean → remove any leftover plaintext .env

Testing

  • bash -n stackctl.sh — syntax OK
  • ./stackctl.sh secrets --help — shows all 4 operations
  • ./stackctl.sh helpsecrets listed in commands
  • .sops.yaml — valid YAML
  • .gitignore.env.enc correctly NOT ignored, .env correctly ignored
  • All READMEs and docs consistent (no stale secrets/ paths)

wax911 added 7 commits June 16, 2026 19:19
Adds encrypt, decrypt, deploy, and clean operations for managing
service-local .env.enc files with SOPS + age. Deploy decrypts,
renders, deploys, and shreds plaintext .env in one step.
- stacks/README.md: add secrets deploy note to doctor and stackctl sections
- README.md: fix duplicate section numbering (two section 5s → 5 and 6)
- proposal: update stale secrets/ paths to service-local .env.enc pattern
- proposal: fix docs/secrets.md reference → docs/Managing Secrets.md
Copilot AI review requested due to automatic review settings June 16, 2026 17:42
@wax911 wax911 force-pushed the chore/sops-age-secrets-setup branch from ce3ba66 to b8c282a Compare June 16, 2026 17:45

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

Introduces a service-local secrets workflow using SOPS + age, integrating it into the repo’s deployment helper (stackctl.sh) so encrypted .env.enc files can be decrypted just-in-time for stack rendering/deploy and then cleaned up.

Changes:

  • Add stackctl.sh secrets subcommand with encrypt|decrypt|deploy|clean operations.
  • Update documentation to describe the new service-local .env.enc workflow and reference it from READMEs.
  • Update SOPS config and gitignore rules to support tracking encrypted env files while ignoring plaintext .env.

Reviewed changes

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

Show a summary per file
File Description
stacks/README.md Adds references to the new secrets deploy workflow alongside existing stackctl guidance.
stackctl.sh Adds secrets subcommand and implementation for encrypt/decrypt/deploy/cleanup of env files.
README.md Documents secrets workflow entry points and fixes section numbering.
docs/proposals/Secrets Management Proposal.md Updates proposal text to reflect the .env.enc approach and Phase 1 status.
docs/Managing Secrets.md Rewrites secrets documentation around SOPS+age + stackctl.sh secrets.
.sops.yaml Updates creation rules intended to support the new env encryption pattern.
.gitignore Ensures encrypted .env.enc files are trackable while plaintext .env remains ignored.

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

Comment thread stackctl.sh Outdated
Comment thread stackctl.sh Outdated
Comment thread stackctl.sh
Comment thread stackctl.sh
Comment thread stackctl.sh
Comment thread stackctl.sh
Comment thread stackctl.sh
Comment thread stackctl.sh Outdated
Comment thread .sops.yaml Outdated
Comment thread docs/Managing Secrets.md Outdated
- per-operation tool checks (no sops/age required for clean)
- service selection now accepts basename or repo-relative path
- encrypt writes to temp file, atomically moves to .env.enc
- decrypt uses umask 077 + temp file + atomic move
- deploy decrypt and cleanup follow same secure pattern
- precise stack detection via env_file path match (no loose grep)
- deploy cleanup only shreds files decrypted in this run
- .sops.yaml path_regex covers both .env and .env.enc
- replace globstar key-rotation example with portable find -exec
@wax911 wax911 merged commit cd6e5bc into dev Jun 16, 2026
5 checks passed
@wax911 wax911 deleted the chore/sops-age-secrets-setup branch June 16, 2026 18:46
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