{"id":15679359,"url":"https://github.com/hideoo/vercel-env-push","last_synced_at":"2025-06-10T17:33:35.090Z","repository":{"id":51362054,"uuid":"508721936","full_name":"HiDeoo/vercel-env-push","owner":"HiDeoo","description":"The missing Vercel CLI command to push environment variables from .env files.","archived":false,"fork":false,"pushed_at":"2023-05-26T18:41:25.000Z","size":179,"stargazers_count":13,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-02T08:22:26.186Z","etag":null,"topics":["cli","env","env-file","environment-variables","push","vercel"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HiDeoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-29T14:18:20.000Z","updated_at":"2024-09-27T09:17:49.000Z","dependencies_parsed_at":"2024-08-10T10:14:11.110Z","dependency_job_id":null,"html_url":"https://github.com/HiDeoo/vercel-env-push","commit_stats":{"total_commits":68,"total_committers":1,"mean_commits":68.0,"dds":0.0,"last_synced_commit":"771aaf31f8215efc64801d271031364af66bfa44"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiDeoo%2Fvercel-env-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiDeoo%2Fvercel-env-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiDeoo%2Fvercel-env-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiDeoo%2Fvercel-env-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HiDeoo","download_url":"https://codeload.github.com/HiDeoo/vercel-env-push/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223806487,"owners_count":17205982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","env","env-file","environment-variables","push","vercel"],"created_at":"2024-10-03T16:29:36.697Z","updated_at":"2024-11-09T09:05:29.542Z","avatar_url":"https://github.com/HiDeoo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003evercel-env-push 🔏\u003c/h1\u003e\n  \u003cp\u003eThe missing \u003ccode\u003evercel env push\u003c/code\u003e command\u003c/p\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://user-images.githubusercontent.com/494699/178267610-2843f230-f048-43d4-88b5-baba6ee00e4d.png\" title=\"Screenshot of vercel-env-push\"\u003e\n      \u003cimg alt=\"Screenshot of vercel-env-push\" src=\"https://user-images.githubusercontent.com/494699/178267610-2843f230-f048-43d4-88b5-baba6ee00e4d.png\" width=\"520\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/HiDeoo/vercel-env-push/actions/workflows/integration.yml\"\u003e\n    \u003cimg alt=\"Integration Status\" src=\"https://github.com/HiDeoo/vercel-env-push/actions/workflows/integration.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/HiDeoo/vercel-env-push/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"License\" src=\"https://badgen.net/github/license/hideoo/vercel-env-push\" /\u003e\n  \u003c/a\u003e\n  \u003cbr /\u003e\u003cbr /\u003e\n\u003c/div\u003e\n\n## Motivations\n\nThe [Vercel command-line interface (CLI)](https://vercel.com/docs/cli) provides a `vercel env pull [file]` command that can be used to pull development environment variables from a Vercel project and write them to a .env file. Unfortunately, the reverse operation is not doable through the Vercel CLI.\n\nAs I couldn't find any other tools providing this functionality with the features I wanted, I decided to write my own which internally uses [`npx`](https://docs.npmjs.com/cli/v8/commands/npx) to run the Vercel CLI either installed locally or fetched remotely.\n\n\u003e **Note**\n\u003e On November 17th 2022, Vercel [released](https://vercel.com/changelog/bulk-upload-now-available-for-environment-variables) bulk upload for environment variables altho this feature is only available through the Vercel Dashboard UI which is an improvement but still not ideal.\n\n## Features\n\n- Usable as a command-line tool or through an API\n- Push to multiple environments at once\n- Ability to add/remove/edit environment variables before pushing\n- Support for [authorization tokens](https://vercel.com/docs/cli#introduction/global-options/token)\n- Dry-run mode\n\n## Usage\n\n### CLI\n\nYou can either add `vercel-env-push` to your project and invoke it with your favorite package manager (or through an entry in your project's `package.json` file):\n\n```shell\n$ pnpm add -D vercel-env-push\n$ pnpm vercel-env-push \u003cfile\u003e \u003cenv\u003e [...otherEnvs]\n```\n\nor use it directly with `npx`:\n\n```shell\n$ npx vercel-env-push \u003cfile\u003e \u003cenv\u003e [...otherEnvs]\n```\n\nThe `file` argument is the path to the .env file containing the environment variables to push. The `env` argument is the name of the environment to push the environment variables to (the supported environments are `development`, `preview` and `production`). You can specify multiple environments by separating them with spaces.\n\n\u003e **Warning**\n\u003e Due to the way the Vercel CLI works, if you have pre-existing environment variables associated to multiple environments (e.g. created through the Vercel Dashboard UI), running `vercel-env-push` to push environment variables to a single environment will remove the environment variables associated to the other environments. Note that environment variables pushed to multiple environments with `vercel-env-push` do not have this limitation as `vercel-env-push` will create a new environment variable for each environment instead of a single one shared across multiple environments.\n\n#### Usage\n\n```shell\n# Push the environment variables from the .env.local file to the preview \u0026 production environments.\n$ pnpm vercel-env-push .env.local preview production\n```\n\n#### Options\n\nThe following options are available through the CLI:\n\n##### `--dry, --dry-run`\n\nList environment variables without pushing them.\n\n```shell\n$ pnpm vercel-env-push .env.local development --dry\n```\n\n##### `-t, --token`\n\nLogin token to use for pushing environment variables.\n\n```shell\n$ VERCEL_ORG_ID=\u003cORG_ID\u003e VERCEL_PROJECT_ID=\u003cPROJECT_ID\u003e pnpm vercel-env-push .env.local development -t \u003cTOKEN\u003e\n```\n\nThis can be especially useful if you ever need to push environment variables [from a CI pipeline](https://vercel.com/support/articles/using-vercel-cli-for-custom-workflows).\n\n```yaml\n- name: Push environment variables from GitHub Actions\n  run: pnpm vercel-env-push .env.local preview -t \"$VERCEL_TOKEN\"\n  env:\n    VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}\n    VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}\n    VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}\n```\n\n##### `-b, --branch`\n\nThe Git branch to apply the environment variables to when pushing environment variables to the Preview environment.\n\n```shell\n$ pnpm vercel-env-push .env.local preview --branch my-preview-branch\n```\n\n### API\n\n`vercel-env-push` can also be used through an API:\n\n```ts\npushEnvVars(envFilePath: string, envs: string[], options?: Options): Promise\u003cvoid\u003e\n```\n\n#### Usage\n\n```ts\nimport { pushEnvVars } from 'vercel-env-push'\n\n// Push the environment variables from the .env.local file to the preview \u0026 production environments.\nawait pushEnvVars('.env.local', ['preview', 'production'])\n```\n\n#### Options\n\n##### `token`\n\nDetermines a [login token](https://vercel.com/docs/cli#introduction/global-options/token) to use for pushing environment variables.\n\n```ts\nimport { pushEnvVars } from 'vercel-env-push'\n\nawait pushEnvVars('.env.local', ['preview', 'production'], {\n  token: process.env.VERCEL_TOKEN,\n})\n```\n\n##### `branch`\n\nDetermines a Git branch to apply the environment variables to when pushing environment variables to the Preview environment.\n\n```ts\nimport { pushEnvVars } from 'vercel-env-push'\n\nawait pushEnvVars('.env.local', ['preview'], {\n  branch: process.env.GIT_BRANCH,\n})\n```\n\n##### `prePush`\n\nSpecifies a callback that can be used to add/remove/edit environment variables before pushing.\n\n```ts\nimport { pushEnvVars } from 'vercel-env-push'\n\nawait pushEnvVars('.env.local', ['preview', 'production'], {\n  prePush: async ({ keyToRemove, ...otherEnvVars }) =\u003e {\n    const secretValue = await getSecretValueFromVault()\n\n    return {\n      ...otherEnvVars,\n      newKey: 'newValue',\n      existingKey: 'updatedValue',\n      secret: secretValue,\n    }\n  },\n})\n```\n\n\u003e **Note**\n\u003e The `dryRun` \u0026 `interactive` options are also available through the API but are mostly useless in this context.\n\n## License\n\nLicensed under the MIT License, Copyright © HiDeoo.\n\nSee [LICENSE](https://github.com/HiDeoo/vercel-env-push/blob/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhideoo%2Fvercel-env-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhideoo%2Fvercel-env-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhideoo%2Fvercel-env-push/lists"}