Deploys · Reference
CLI
mybeast-deploy runs your deploy or rollback command as it is and reports it to Deploys. One bash file: bash 3.2 or later and curl, nothing else.
Install
Download it from the latest release of my-beast/cli into a folder on your PATH:
mkdir -p ~/.local/bin
curl -fsSLo ~/.local/bin/mybeast-deploy https://github.com/my-beast/cli/releases/latest/download/mybeast-deploy
chmod +x ~/.local/bin/mybeast-deploy
mybeast-deploy --versionIn CI, pin a release instead of latest: https://github.com/my-beast/cli/releases/download/v0.1.0/mybeast-deploy. See Deploy from CI.
Check the download
Each release lists its files' SHA-256 sums in SHA256SUMS. To check the file against them:
cd ~/.local/bin && curl -fsSL https://github.com/my-beast/cli/releases/latest/download/SHA256SUMS | grep ' mybeast-deploy$' | shasum -a 256 -c -It prints mybeast-deploy: OK, or ends with an error when the file is not the one released.
Settings
| Variable | What it is |
|---|---|
MYBEAST_DEPLOYS_URL | Deploys' address, https://services.my-beast.com/deploys. It must be https://. |
MYBEAST_DEPLOYS_KEY | A Deploys server secret of the project, sk_….…, made in the project's Settings under Deploys keys. |
MYBEAST_DEPLOYS_CONFIG | Another settings file than ~/.config/mybeast/deploys.env. |
Export them, or write them into the settings file as NAME=value lines (export and quotes are allowed). A variable that is exported wins over the file. With XDG_CONFIG_HOME set, the file is in that folder instead of ~/.config.
The file is read, never run, and refused while anyone but you can read it: chmod 600 it. The key goes to curl on its standard input, never on a command line where other users' ps would see it.
Commands
| Command | What it does |
|---|---|
mybeast-deploy run --app APP --env ENV [--release NAME] [--yes] [-- COMMAND [ARGS...]] | Runs COMMAND and reports it as a deploy: who, the commit, its output as it comes, how it ended. Without a command, it runs the app's own deploy command from its Settings, after a yes. |
mybeast-deploy rollback --app APP --env ENV [--to RELEASE] [--yes] [-- COMMAND [ARGS...]] | The same for going back: reported as a rollback, and without a command it runs the app's own rollback command. It sends no commits. |
mybeast-deploy status --app APP [--env ENV] | Prints the app's name and its saved deploy and rollback commands. With --env, also what is live there (release, deploy, who, when) and how the last deploy there ended. It runs nothing. |
mybeast-deploy --version | Prints its version. -v is the same. |
mybeast-deploy --help | Prints the commands above. -h and help are the same. |
Run them from the app's folder: its git checkout says the commit.
Flags
| Flag | For | What it does |
|---|---|---|
--app APP | all | The app's key: lower-case letters, digits and inner dashes, up to 40 characters, such as shop. A key Deploys has not seen adds the app on its first deploy. |
--env ENV | all | One of the project's environments, such as staging: lower-case letters, digits, - and _, up to 32 characters. Needed by run and rollback; optional for status. |
--release NAME | run | What this build is called, when its log does not say it: 1 to 64 letters, digits and . _ + -. See the release name. |
--to RELEASE | rollback | The release to go back to. The command gets it as RELEASE=<release> in its environment, and the rollback is recorded as going to that release. |
--yes, -y | run, rollback | Answers yes for you when no command is given and the app's own would be run: for CI and other runs without a terminal. |
-- COMMAND | run, rollback | Everything after -- is the command, run as it is. Leave -- out to run the app's own command. |
A flag's value may also follow an equals sign, as in --app=shop. Flags go before --; everything after it belongs to your command.
What it sends
When a deploy starts:
- the app, the environment, and whether it is a deploy or a rollback;
- the command as it is shown, with the value of anything that looks like a secret taken out;
- the commit, its subject and the branch, whether the checkout had uncommitted changes, and for a deploy the checkout's last 50 commits (hash, author, subject);
- git's
user.nameanduser.email, the machine's name and the system user; - its own version, and the release named by
--releaseor--to.
While it runs, your command's output, every 2 seconds, in batches of whole lines up to 256 KB, colours and all. With no new output it says it is still there every 30 seconds. A batch whose answer was lost is sent again and kept once. At the end: how it ended, the exit code and how long it took.
It never sends the key to your command, and never what you type at your command's prompts: those go from the terminal to the command. See Data and privacy.
The command's environment
Your command runs with the terminal, so its prompts work as without mybeast-deploy. Its output and its errors both go to the terminal at once and to the log. Ctrl-C goes to the command: its own clean-up runs, and the deploy is reported as stopped. It finds these variables beside your own:
| Variable | What it holds |
|---|---|
MYBEAST_DEPLOY_ID | The deploy's id, empty when the service did not take the deploy. |
MYBEAST_DEPLOY_PAGE | The deploy's page, the address mybeast-deploy printed. |
RELEASE | Set by rollback --to RELEASE only: the release to go back to. |
MYBEAST_DEPLOYS_KEY is taken out of the command's environment.
When the service is down
Deploys being unreachable never stops a deploy. mybeast-deploy says what happened instead:
not reported: … - the command runs all the same: the start was refused or never arrived. The command runs unreported, and the line says why.the log did not all reach the service: the whole log is kept on the machine, in$TMPDIR/mybeast-deploy-<id>.log.how it ended was not reported: Deploys marks the deploy lost after 10 minutes with no word.
Exit codes
| Code | When |
|---|---|
| The command's own | run and rollback end with the exit code of the command they ran, reported or not: 0 when it succeeded. A job in CI fails when the deploy fails. |
| 2 | mybeast-deploy refused before running anything: a flag it does not know, a setting missing or the wrong shape, a settings file others can read, no command given and none saved, or no yes. For status: the app could not be read. |
| 0 | status, --version and --help when they print what they were asked. |
Try it
The CLI's repository has two demo scripts in deploy/examples that talk like a real deploy and deploy nothing: --fail makes the deploy fail, and --ask asks for a deploy password first.
git clone https://github.com/my-beast/cli.git && cd cli/deploy
./mybeast-deploy run --app demo --env staging -- examples/demo-deploy.sh
./mybeast-deploy run --app demo --env staging -- examples/demo-deploy.sh --fail
./mybeast-deploy rollback --app demo --env staging -- examples/demo-rollback.shThey report to your project like any deploy: --app demo adds an app called Demo, which counts toward your package's apps and keeps its history. Don't run them as a real app, whose page would then show a demo release as live.