Skip to content

Instantly share code, notes, and snippets.

@davidlee
Last active March 27, 2026 06:50
Show Gist options
  • Select an option

  • Save davidlee/90a577666971045a4cf0035366347edc to your computer and use it in GitHub Desktop.

Select an option

Save davidlee/90a577666971045a4cf0035366347edc to your computer and use it in GitHub Desktop.
1password .env socket -> vercel pubish script
#!/usr/bin/env zsh
# reads .env socket (1password environment secrets)
# and sets them as Vercel sensitive environment vars.
# takes the environment name as argument:
#
# ./sync-env.zsh production
# ./sync-env.zsh staging
# ./sync-env.zsh development
set -euo pipefail
target_env=${1:-production}
typeset -A seen
env_blob=$(<.env)
for line in ${(f)env_blob}; do
[[ -z $line || $line = \#* ]] && continue
key=${line%%=*}
value=${line#*=}
[[ -n ${seen[$key]:-} ]] && continue
seen[$key]=1
printf %s "$value" |
pnpx vercel env add "$key" "$target_env" --sensitive --force
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment