Getting Started
Sync environment variables from 1Password to Vercel, GitHub, and CircleCI
@octopus-energy/env provides the oe.env CLI, which reads environment
variables from 1Password via
varlock and syncs them to Vercel,
GitHub Actions, and/or CircleCI.
Requirements
| Requirement | Version |
|---|---|
| Node.js | ≥24.0.0 |
| Peer dependency | Version | When |
|---|---|---|
varlock | ^1.9.0 | Required |
vercel | >=54.0.0 | Syncing to Vercel |
Quick start
Install the package
Install the CLI package, varlock, and the 1Password plugin:
npm i @octopus-energy/env varlock @varlock/1password-pluginInstall the service CLIs only for the services you sync to. Use the Vercel CLI when syncing to Vercel, and use the GitHub CLI when syncing to GitHub Actions. CircleCI syncs do not require a local CLI.
Configure 1Password CLI
Install the 1Password CLI, then enable the desktop app integration and Touch ID.
On macOS, you can install the CLI with Homebrew:
brew install 1password-cliOpen the 1Password developer settings and enable the CLI integration:
open onepassword://settings/developersOpen the 1Password security settings and enable Touch ID:
open onepassword://settings/securityTouch ID is strongly recommended for local development. It allows varlock to resolve 1Password references without repeatedly prompting for credentials.
Create 1Password items
Create a 1Password item for the project and add the values referenced by the schema:
| Field | Example value |
|---|---|
MY_SECRET | secret-value-to-sync |
The examples below use op://Vault/Project/... placeholders. Replace them with
the vault, item, and field names for your project.
Configure varlock
Create a .env.schema file in the target project. See the
varlock schema guide for the full schema
syntax and the 1Password plugin guide
for @varlock/1password-plugin setup details.
# @plugin(@varlock/1password-plugin)
# @initOp(allowAppAuth=true, account=octoenergy)
# @currentEnv=$APP_ENV
# @defaultSensitive=inferFromPrefix('NEXT_PUBLIC_')
# ---
# @type=enum(development, preview, production, test)
# Note: "test" is valid for local use but is not a sync target environment.
APP_ENV=development
OE_ENV_CIRCLE_CI_PROJECT=github/my-org/my-repo
MY_SECRET=op("op://Vault/Project ${APP_ENV}/MY_SECRET")During sync, oe.env resolves this schema once per source environment using
that environment's APP_ENV value.
Reserved OE_ENV_ prefix
Use OE_ENV_ variables for sync routing and tool configuration, for example
OE_ENV_VERCEL_PROJECT, OE_ENV_GITHUB_ENVIRONMENT, or OE_ENV_TERRITORY. Variables with this
prefix are never synced to target services.
Update scripts to use varlock run
Prefix any script that needs environment variables with varlock run -- so
varlock resolves the schema and injects the values before the command runs:
{
"scripts": {
"dev": "varlock run -- next dev",
"build": "varlock run -- next build",
"start": "varlock run -- next start"
}
}Scripts that do not read environment variables, such as linting, type checking, and code generation, do not need the prefix.
Next.js integration recommended
For Next.js projects, we recommend using Varlock's Next.js plugin instead of varlock run. The
plugin adds log redaction, leak detection, and encrypted deployments. See the Next.js integration
recipe.
Run the CLI
Check that varlock and your target services are configured correctly:
npm exec oe.env statusThen run a dry sync to preview the plan:
npm exec oe.env sync --dry-run