Guide · Deploy

Push env vars to your deploy platforms

Your keys live in one place on your Mac and in a dashboard for each service that runs your code. Every change means pasting the same value again, and nobody remembers which copy is stale.

In shortLink an environment once with lk remote link, check it with lk remote status, and send it with lk push. Every push asks you to approve it, and nothing is deployed: new values apply on the service's next deploy.

Why the copies drift

A deployed app can't read your keychain, so each platform keeps its own copy of every value. Vercel has one, GitHub Actions has another, Railway and Fly have more. You change a key on your Mac, paste it into one dashboard, and forget the other two. Weeks later a build fails and nothing says which copy is old.

Latchkey can hold the list of places an environment goes. It then compares names and sends values from one place.

Push an environment

The examples use a project called shop with a production environment. Install and sign in to the tool for each service you use first: vercel login, gh auth login, railway login or flyctl auth login. By default Latchkey runs those tools as you and stores no service tokens.

  1. Link the environment

    Each link names a service and the target on it. Linking asks for approval. A link covers the whole environment, including items you add later.

    Terminal
    lk remote link shop/vercel.preview vercel project=shop environment=preview
    lk remote link shop/production github repo=me/shop environment=production
    lk remote link shop/production fly app=shop-api

    In the app, open an item's Edit menu, choose Remote Locations…, then Add a Location…. The sheet asks for the service's details and says whether its command-line tool is installed. Add Location turns on once the details are complete. It never asks for a service token.

  2. Check what differs

    Status shows names missing on each side, and items whose value changed since they were last pushed. It compares names and doesn't use values.

    Terminal
    lk remote status shop/production
  3. Rehearse, then push

    Use --dry-run for a first look before a real push. Then run the push. You can limit it to one link with --to or to chosen items with --only.

    Terminal
    lk push shop/production --dry-run
    lk push shop/production
    lk push shop/production --to LINK_ID --only shop/production/DATABASE_URL

    Every push asks, every time, and no grant covers one. A production target also needs I mean to change production ticked in the approval panel. The Latchkey app does the pushing, so it must be running; lk push asks it. With a command-line tool, values reach the tool on standard input, never as arguments. Find a link's ID for --to with lk remote list shop/production.

  4. See what changed since the last push

    After a push, Latchkey records when each item went to each link. An item changed since then gets an orange badge in the list and "Changed since last push" in its detail. Review has a Changes filter that lists those items, and also items not pushed yet, with a Push… action.

Push through an API instead

If you'd rather not depend on the command-line tools, keep the service's access token as an ordinary Latchkey item and name it in the link. Use a token limited to what you push.

Terminal
lk set VERCEL_TOKEN --kind token
lk remote link shop/vercel.preview vercel project=shop environment=preview token=VERCEL_TOKEN

The Mac App Store version can only push this way, and it can't push to GitHub. The CLI reference lists every key each service takes.

A service on a Linux server

A service on your own Linux server can read its credentials from files, for example a systemd unit with LoadCredential=. Give the server a script that stores one credential from standard input, and link the environment to it over ssh. Name each item ADAPTER.ACCOUNT:

Terminal
lk set distribution/production/bluesky.someone.bsky.social --kind token
lk remote link distribution/production ssh host=myserver script=/srv/app/add-credential.sh
lk push distribution/production

Latchkey runs sudo -n bash SCRIPT ADAPTER ACCOUNT --stdin on the server once per item, with your SSH keys and the value on standard input, and counts it as pushed only when the script prints stored ADAPTER.ACCOUNT. Your account needs a sudoers rule to run that script without a password. Every push to a server counts as production, since the script restarts the service. The script contract has the details; the direct download only.

What this doesn't do

Related