naut-cli
A cli client for SilverStripe's deploynaut., (*1)
Install
Download the latest phar from the releases section of this repo and put it somewhere
on your $PATH
., (*2)
Or you can clone this repository and build the phar yourself by following
the instructions in the Build section below., (*3)
Configuration
naut-cli can be configured in two ways., (*4)
- By creating a
.naut.env
file in the users home directory (generated with the naut-cli configure
command)
- By setting the required environment variables before running any naut-cli commands
Required environment variables
If you are not going to use a .naut.env
file in your home directory, these environment variables
must be set:, (*5)
-
NAUT_URL
: the URL of the deploynaut instances
-
NAUT_USERNAME
: your deploynaut username
-
NAUT_TOKEN
: your deploynaut API token
Usage
There are a few different commands that can be run., (*6)
naut-cli can be configured by placing a .naut.env
file in your home directory., (*7)
You can create this file interactively by running:, (*8)
php naut-cli.phar configure
This will ask you for:, (*9)
- The domain of deploynaut (e.g. https://deploy.test.com)
- Your username (e.g. test@test.com)
- Your deploynaut API token
And create a new file at ~/.naut.env
that is only readable by the current user., (*10)
Deploy
Deploy the latest commit of a project to a specific environment with deploy:, (*11)
php naut-cli.phar deploy <project_id> <environment> <branch_name>
Where:, (*12)
-
<project_id>
is the short text identifier of the project in deploynaut (also seen in the deploynaut URL at /naut/project/<project_id>
)
-
<environment>
is the name of the environment you want to deploy to (e.g. 'prod
', 'uat
', 'test1
')
-
<branch_name>
is the name of the git branch you would like to deploy
A few things will happen when you run this command:, (*13)
- Fetch latest changes from git
- Trigger deployment
- Stream the deployment log back to your terminal
Snapshots
List
You can see a list of snapshots for a specific stack with the command:, (*14)
php naut-cli.phar snapshot:list <stack_id>
This will display a table containing columns for: the snapshot id, source environment, mode, size, and created date/time., (*15)
Delete
You can delete a snapshot with the command:, (*16)
php naut-cli.phar snapshot:delete <stack_id> <snapshot_id>
Create
You can create a new snapshot for a specific stack/environment with the command:, (*17)
php naut-cli.phar snapshot:create <stack_id> <snapshot_id>
Optionally, you can include the --mode
flag. This flag sets the type of snapshot to create., (*18)
Valid options are:, (*19)
The default if the --mode
flag is missing is all
. Example usage: --mode=assets
., (*20)
Download
You can download a snapshot with the command:, (*21)
php naut-cli.phar snapshot:download <stack_id> <snapshot_id>
By default, this command will save the snapshot to the current directory with the same name as it exists within the dashboard.
It will also display a progress bar while downloading by default., (*22)
If you would like to save to a different location/filename then you can use he --to-stdout
option, and run the command like:, (*23)
php naut-cli.phar snapshot:download <stack_id> <snapshot_id> --to-stdout > /path/to/your/file.sspak
When downloading this way the progress bar is not displayed., (*24)
Build phar from source
To build the naut-cli.phar
file from source run the script bin/build-phar.sh
., (*25)
This will create a fresh copy of the phar at dist/naut-cli.phar
., (*26)
To do
- Implement more of the deploynaut API