Skip to content

Latest commit

 

History

History
115 lines (84 loc) · 3.21 KB

README.md

File metadata and controls

115 lines (84 loc) · 3.21 KB

Elvis - Git automation


Love me tender

Elvis is a simple open-source automation tool for operations on multiple Git repositories written on PHP.

It can be used to, for example, monthly update changelogs or documentation pages on your projects.

Elvis makes these steps:

  1. Clone repository
  2. Checkout defined branch
  3. Perform set of commands inside repository's folder
  4. If any new files created, add them to repository
  5. Commit changes
  6. Push

Install and requirements

To run Elvis, you will need

  • PHP 7.0+
  • Git

First off, copy elvis file from this repository to any folder you have write permissions for, because Elvis will create temporary files and folders in this folder. Then, create config.json file in same folder. You can copy its content from example config.example.json file. Read more about config file below.

Usage

php elvis [config file]

If no config file provided, Elvis expects config.json in current directory.

Elvis will use SSH key to clone/push repositories. You can generate a separate key with ssh-keygen -f pkey, then you will need to copy content of pkey file to private key in config file, and add pkey.pub as SSH key for user in your Git system (Github, Gitlab).

You can also have separate keys for each repository.

Note, that this user need to have write access rights for desired branch.

Configuration

Example of configuration can be found in config.example.json.

{
  "actions": {
    "update guestbook": {
      "commit message": "Update GUESTBOOK.md",
      "commands": [
        "echo \"Elvis was here\" > GUESTBOOK.md"
      ]
    }
  },
  "defaults": {
    "private key": "-----BEGIN OPENSSH PRIVATE KEY-----\nSuper secret!\n-----END OPENSSH PRIVATE KEY-----\n"
  },
  "repositories": [
    {
      "url": "[email protected]:nikserg/elvis.git",
      "actions": [
        "update guestbook"
      ]
    }
  ]
}

Let's see on parts of this file.

defaults

Options, provided by default, if no more specific option provided in action or repository.

  • private key - SSH private key to connect to repository. Can be overridden in repositories
  • commit message - commit message for changes. Can be overridden in actions. Default: "Elvis"
  • git name, git email - git credentials. Can be overridden in repositories. Default: Elvis Presley <[email protected]>
  • actions - list of actions to perform on each repository. Can be overridden in repositories.
  • branch - branch to checkout. Default: main.

actions

List of available actions, which can be performed on repository. Each action contains list of commands.

  • actions - list of commands
  • commit message - surprisingly, a commit message for all changes

repositories

List of repositories to clone and perform actions.

  • url - URL of git repository
  • actions - list of actions

Also, you can define list of repositories as list of URLs, if all actions, keys, branches etc. are default. Like this:

{
  "repositories": [
    "[email protected]:nikserg/elvis.git",
    "[email protected]:FriendsOfSymfony/FOSRestBundle.git",
    "[email protected]:mehdi-fathi/eloquent-filter.git"
  ]
}