A CLI tool to batch sync GitHub Actions secrets across multiple repositories. Sync secrets from a central repository to target repositories using GitHub CI.
Managing GitHub Actions secrets across multiple repositories can be tedious:
- Manual repetition: You need to manually add the same secret to each repository
- Error-prone: Easy to forget to update a secret in one of the repositories
This tool automates the process, allowing you to sync secrets across multiple repositories with a single command.
Create a configuration file (secrets.config.yaml
) in your central repository or local directory:
repos:
- owner/vscode-*
envs:
- VSCE_PAT
- OVSX_PAT
Note
Both repos
and envs
support *
wildcards. For repos
, the tool lists all repositories accessible by your token and filters by the pattern (e.g., owner/vscode-*
). For envs
, wildcards are expanded by listing secrets from the central repository and matching by name. The central repository is auto-detected in GitHub Actions (from the checked-out repo); for local runs, pass --repo <owner/repo>
.
If GitHub CI feels too complex, you can simply run it locally:
# Set your token and secret values in env
export GITHUB_PAT=...
export VSCE_PAT=...
export OVSX_PAT=...
npx gh-secrets-sync
Set up GitHub CI in your central repository:
# .github/workflows/sync-secrets.yml
name: Sync Secrets
permissions:
contents: write
on:
push:
branches: [main]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Sync Secrets
# if regex patterns are used in `repos` or `secrets` must set `--yes` in GitHub Actions
run: npx gh-secrets-sync --yes
env:
GITHUB_PAT: ${{secrets.GITHUB_PAT}}
VSCE_PAT: ${{secrets.VSCE_PAT}}
OVSX_PAT: ${{secrets.OVSX_PAT}}
Configure secrets in your central repository:
- Go to your central repository Settings > Secrets and variables > Actions
- Add
GITHUB_PAT
as a repository secret (this is your GitHub Personal Access Token) - Add
VSCE_PAT
andOVSX_PAT
as repository secrets
- Go to GitHub Personal Access Tokens
- Click "Generate new token"
- Give it a descriptive name like "Secrets Sync Tool"
- Select the required scopes:
- Repository permissions > Secrets: Read and write
- Repository permissions > Actions: Read and write
- Metadata
- Click "Generate token"
- Add the token as a repository secret named
GITHUB_PAT
in your central repository
MIT License © jinghaihan