Minimalistic SSH deployment.
Copy this one-liner and run it in your shell:
SHPT=/usr/local/bin/shipit && curl -o $SHPT https://raw.githubusercontent.com/sapegin/shipit/master/bin/shipit && chmod +x $SHPT && unset SHPT
You can use this command to update shipit too.
Note: Use sudo
or replace /usr/local/bin/shipit
to path somewhere inside your home directory.
shipit [option] <command>
Command | Aliases | Description |
---|---|---|
<target> |
Execute target target on the remote host |
|
list | ls | Print list of available targets |
console | shell, ssh | Open an SSH session on remote host |
exec <cmd> |
run | Execute cmd on the remote host |
copy <file> |
cp | Copy files to the remote host |
--version | -V | Print shipit version |
--help | -h | Print help |
Option | Description |
---|---|
-c, --config | Config file path (default: .shipit ) |
-r, --remote | Override remote host |
-v, --verbose | Enable verbose mode for SSH |
Execute deploy
target:
shipit
Execute status
target:
shipit status
Show a list of available targets:
shipit list
Execute uptime
command on the remote host:
shipit exec uptime
You need to create .shipit
file in your project’s directory.
Here is a typical config:
host='myhost'
path='sites/example.com'
[deploy:local]
git push origin master
[deploy]
git checkout master
git pull
npm install
grunt build
[status]
uptime
The only required things are host
and path
parameters, and [deploy]
or [deploy:local]
target.
For non-standard port number and to specify which SSH key to use, edit your SSH config, ~/.ssh/config
:
host example.com
IdentityFile ~/.ssh/keyfile
port 10022
user usernamehere
It’s the same host you use in ssh
command. It could be string of format <username>@<ip>:<port>
or just a name of ~/.ssh/config
record.
Project path on remote host. shipit will cd
to this directory before executing any command.
Target is just a bunch of shell command that will be executed on remote host via SSH. You can define as many targets as you want.
Note that you can’t use blank lines inside targets but you can use comments (#) and other things—it’s just a shell script.
If you append :local
to a target name (like [name:local]
) it will be executed on your local machine before remote target with the same name. You can define only local, only remote or both targets.
In case of any errors in local target remote target won’t be executed.
You can use these variables:
$SSH_HOST
— your config’shost
value,$SSH_PATH
— your config’spath
value.
host='myhost'
path='sites/example.com'
[deploy:local]
git push origin master
[deploy]
git checkout master
git pull
npm install
npm prune
npm run build
host='myhost'
path='sites/example.com'
[deploy:local]
npm test
npm run build
rsync --archive --compress --force --delete public/ $SSH_HOST:$SSH_PATH
The changelog can be found on the Releases page.
This software has been developed with lots of coffee, buy me one more cup to keep it going.
Artem Sapegin and contributors.
MIT License, see the included License.md file.