feat(secrets): add SOPS + age secrets management with stackctl.sh integration#491
Merged
Conversation
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
ce3ba66 to
b8c282a
Compare
There was a problem hiding this comment.
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 secretssubcommand withencrypt|decrypt|deploy|cleanoperations. - Update documentation to describe the new service-local
.env.encworkflow 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.
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adopt the service-local
.env.encSOPS+age pattern (matching../../docker/) for encrypting secrets at rest in git, with just-in-time decryption at deploy time viastackctl.sh secrets.Changes
.sops.yamlsecrets/path regex with\.env$, usekey_groups→ageformat with real public key.gitignore!*.env.encallowlist so encrypted files are trackedstackctl.shsecretssubcommand:encrypt,decrypt,deploy,cleandocs/Managing Secrets.md.env.encworkflowREADME.mdstacks/README.mddocs/proposals/Secrets Management Proposal.mdsecrets/pathsNew
stackctl.sh secretscommandsWorkflow
cp service/.env.example service/.env→ fill in real values./stackctl.sh secrets encrypt service→ commits.env.enc./stackctl.sh secrets deploy service→ decrypt, render, deploy, shred./stackctl.sh secrets clean→ remove any leftover plaintext.envTesting
bash -n stackctl.sh— syntax OK./stackctl.sh secrets --help— shows all 4 operations./stackctl.sh help—secretslisted in commands.sops.yaml— valid YAML.gitignore—.env.enccorrectly NOT ignored,.envcorrectly ignoredsecrets/paths)