Skip to content

GitHub CLI command to provision environments with secrets and variables from a configuration file.

License

Notifications You must be signed in to change notification settings

AyogoHealth/gh-provision-envs

Repository files navigation

GitHub Environment Provisioning

A GitHub CLI command to provision environments with secrets and variables from a configuration file.

Requirements

  • The GitHub CLI tool
  • Administrative permissions on the GitHub repositories you want to run this on
  • NodeJS 18.x or newer

Usage

You can install this as an extension to the gh CLI tool. At its simplest, you give it a JSON config file and a repository name:

gh extension install AyogoHealth/gh-provision-envs
gh provision-envs -c config.json -R myuser/myrepo

Disclaimers

  • This will overwrite variable and secret values if they already exist!
  • This is a bit of a hack, cobbled together by spawning other gh commands
  • If your secret/variable values contain double quotes, you'll maybe have a bad time...
  • If you try to break it, you almost definitely will

Config File Format

The config file must be a valid JSON file, consisting of an object with an environments key that contains the environments you would like to provision.

Example

{
  "environments": {
    "staging": {
      "variables": [
        {
          "name": "HOSTNAME",
          "value": "staging.example.com"
        }
      ],
      "secrets": [
        {
          "name": "DEPLOY_KEY_PASSWORD",
          "value": "MySecretPassword1"
        }
      ]
    },
    "production": {
      "variables": [
        {
          "name": "HOSTNAME",
          "value": "example.com"
        }
      ],
      "secrets": [
        {
          "name": "DEPLOY_KEY_PASSWORD",
          "value": "MySecretPassword2"
        },
        {
          "name": "SECRET_PRODUCTION_VALUE",
          "value": "ThisIsASecret"
        }
      ]
    }
  }
}

Contributing

Contributions of bug reports, feature requests, and pull requests are greatly appreciated!

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Licence

Released under the MIT Licence.

Copyright © 2023 Ayogo Health Inc.

About

GitHub CLI command to provision environments with secrets and variables from a configuration file.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks