It can be used to, for example, monthly update changelogs or documentation pages on your projects.
Elvis makes these steps:
- Clone repository
- Checkout defined branch
- Perform set of commands inside repository's folder
- If any new files created, add them to repository
- Commit changes
- Push
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.
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.
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.
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 inrepositories
commit message
- commit message for changes. Can be overridden inactions
. Default: "Elvis"git name
,git email
- git credentials. Can be overridden inrepositories
. Default:Elvis Presley <[email protected]>
actions
- list of actions to perform on each repository. Can be overridden inrepositories
.branch
- branch to checkout. Default:main
.
List of available actions, which can be performed on repository. Each action contains list of commands.
actions
- list of commandscommit message
- surprisingly, a commit message for all changes
List of repositories to clone and perform actions.
url
- URL of git repositoryactions
- 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"
]
}