{"id":13509086,"url":"https://github.com/tj/robo","last_synced_at":"2025-04-04T08:07:21.299Z","repository":{"id":30162865,"uuid":"33713164","full_name":"tj/robo","owner":"tj","description":"Simple Go / YAML-based task runner for the team.","archived":false,"fork":false,"pushed_at":"2022-10-19T16:29:48.000Z","size":60,"stargazers_count":787,"open_issues_count":13,"forks_count":48,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-10-30T02:37:25.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tj.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-10T06:46:30.000Z","updated_at":"2024-09-20T13:47:04.000Z","dependencies_parsed_at":"2022-07-12T15:50:48.601Z","dependency_job_id":null,"html_url":"https://github.com/tj/robo","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Frobo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Frobo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Frobo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Frobo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj","download_url":"https://codeload.github.com/tj/robo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142065,"owners_count":20890652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:02.760Z","updated_at":"2025-04-04T08:07:21.263Z","avatar_url":"https://github.com/tj.png","language":"Go","funding_links":[],"categories":["Go","others"],"sub_categories":[],"readme":"\n# Robo\n\n [![Build Status](https://travis-ci.org/tj/robo.svg?branch=master)](https://travis-ci.org/tj/robo)\n\n Simple YAML-based task runner written in Go.\n\n ![](http://img1.wikia.nocookie.net/__cb20130827204332/callofduty/images/f/fa/Giant_mech_Origins_BOII.png)\n\n## Features\n\n - Not super slow\n - Not super obscure\n - No dependencies\n - Variables\n - Simple\n\n## Installation\n\nFrom [gobinaries.com](https://gobinaries.com):\n\n```sh\n$ curl -sf https://gobinaries.com/tj/robo | sh\n```\n\nFrom source:\n\n```\n$ go get github.com/tj/robo\n```\n\n## Usage\n\n Command-line usage.\n\n### Listing tasks\n\n Output tasks:\n\n```\n$ robo\n\n  aws – amazon web services cli\n  circle.open – open the repo in circle ci\n  events – send data to the \"events\" topic\n  push – push image from the current directory\n\n```\n\n### Task help\n\n Output task help:\n\n```\n$ robo help events\n\n  Usage:\n\n    events [project-id] [rate]\n\n  Description:\n\n    send data to the \"events\" topic\n\n  Examples:\n\n    Send 25 events a second to gy2d\n    $ robo events gy2d 25\n\n```\n\n### Running tasks\n\n Regardless of task type (shell, exec, script) any additional arguments\n given will be passed.\n\n For example suppose you have the following task:\n\n```yml\naws:\n  exec: ssh tools aws\n```\n\n You may then interact with the AWS cli as you would normally:\n\n```\n$ robo aws help\n$ robo aws ec2 describe-instances\n```\n\n## Configuration\n\n Task configuration.\n\n### Commands\n\n The most basic task simply runs a shell command:\n\n```yml\nhello:\n  summary: some task\n  command: echo world\n```\n\n You may also define multi-line commands with YAML's `|`:\n\n```yml\nhello:\n  summary: some task\n  command: |\n    echo hello\n    echo world\n```\n\n Commands are executed via `sh -c`, thus you may use shell features and\n positional variables, for example:\n\n```yml\nhello:\n  command: echo \"Hello ${1:-there}\"\n```\n\n Yields:\n\n```\n$ robo hello\nHello there\n\n$ robo hello Tobi\nHello there Tobi\n```\n\n\n### Exec\n\n The exec alternative lets you replace the robo image without\n the fork \u0026 shell, however note that shell features are not\n available (pipes, redirection, etc).\n\n```yml\nhello:\n  summary: some task\n  exec: echo hello\n```\n\n Any arguments given are simply appended.\n\n### Scripts\n\n Shell scripts may be used instead of inline commands:\n\n```yml\nhello:\n  summary: some task\n  script: path/to/script.sh\n```\n\n If the script is executable, it is invoked directly, this allows you\n to use `#!`:\n\n```\n$ echo -e '#!/usr/bin/env ruby\\nputs \"yo\"' \u003e yo.rb\n$ chmod +x yo.rb\n$ cat \u003e robo.yml\nyo:\n  summary: yo from rb\n  script: yo.rb\n^C\n$ robo yo\nyo\n```\n\nScript paths are relative to the _config_ file, not the working directory.\n\n### Usage\n\n Tasks may optionally specify usage parameters, which display\n upon help output:\n\n```yml\nevents:\n  summary: send data to the \"events\" topic\n  exec: docker run -it events\n  usage: \"[project-id] [rate]\"\n```\n\n### Examples\n\n Tasks may optionally specify any number of example commands, which\n display upon help output:\n\n```yml\nevents:\n  summary: send data to the \"events\" topic\n  exec: docker run -it events\n  usage: \"[project-id] [rate]\"\n  examples:\n    - description: Send 25 events a second to gy2d\n      command: robo events gy2d 25\n```\n\n### Variables\n\n Robo supports variables via the [text/template](http://golang.org/pkg/text/template/) package. All you have to do is define a map of `variables` and use `{{` `}}` to refer to them.\n\n Here's an example:\n\n```yml\nstage:\n  summary: Run commands against stage.\n  exec: ssh {{.hosts.stage}} -t robo\n\nprod:\n  summary: Run commands against prod.\n  exec: ssh {{.hosts.prod}} -t robo\n\nvariables:\n  hosts:\n    prod: bastion-prod\n    stage: bastion-stage\n```\n\nThe variables section does also interpolate itself with its own data via `{{ .var }}` and allows shell like command \nexpressions via `$(echo true)` to be executed first providing the output result as a variable. Note that variables are \ninterpolated first and then command expressions are evaluated. This will allow you to reduce repetitive variable definitions and declarations. \n\n````bash\nhash:\n  summary: echos the git {{ .branch }} branch's git hash\n  command: echo {{ .branch }} {{ .githash }}\n\nvariables:\n  branch: master\n  githash: $(git rev-parse --short {{ .branch }})\n````\n\n  Along with your own custom variables, robo defines the following variables:\n\n```bash\n$ robo variables\n\n    robo.file: /Users/amir/dev/src/github.com/tj/robo/robo.yml\n    robo.path: /Users/amir/dev/src/github.com/tj/robo\n\n    user.home: /Users/amir\n    user.name: Amir Abushareb\n    user.username: amir\n\n```\n\n### Environment\n\nTasks may define `env` key with an array of environment variables, this allows you\nto re-use robo configuration files, for example:\n\n```yaml\n// aws.yml\ndev:\n  summary: AWS commands in dev environment\n  exec: aws\n  env: [\"AWS_PROFILE=eng-dev\"]\n\nstage:\n  summary: AWS commands in stage environment\n  exec: aws\n  env: [\"AWS_PROFILE=eng-stage\"]\n\nprod:\n  summary: AWS commands in prod environment\n  exec: aws\n  env: [\"AWS_PROFILE=eng-prod\"]\n```\n\nYou can also override environment variables:\n\n```bash\n$ cat \u003e robo.yml\nhome:\n  summary: overrides $HOME\n  exec: echo $HOME\n  env: [\"HOME=/tmp\"]\n^C\n$ robo home // =\u003e /tmp\n```\n\nVariables can also be used to set env vars.\n\n```bash\n$ cat \u003e robo.yml\naws-stage:\n  summary: AWS stage\n  exec: aws\n  env: [\"AWS_PROFILE={{.aws.profile}}\"]\nvariables:\n  aws:\n    profile: eng-stage\n^C\n$ robo aws-stage ...\n```\n\nNote that you cannot use shell featurs in the environment key.\n\n### Setup / Cleanup\nSome tasks or even your entire robo configuration may require steps upfront for setup or afterwards for a cleanup. The keywords `before` and `after` can be embedded into a task or into the overall robo configuration. It has the same executable syntax as a task: `script`, `exec` and `command`.\nDefining it on a task level causes the steps to be executed before (respectively after) the task. Global before or after steps are invoked for _every_ task in the configuration.\nAll steps get interpolated the same way tasks and variables are interpolated.\n\n```yaml\nbefore:\n  - command: echo \"global before {{ .foo }}\"\nafter:\n  - script: /global/after-script.sh\n\nfoo:\n  before:\n    - command: echo \"local before {{ .foo }}\"\n    - exec: git pull -r\n  after:\n    - command: echo \"local after\"\n    - exec: git reset --hard HEAD\n  exec: git status\n\nvariables:\n  foo: bar\n```\n\n### Templates\n\n Task `list` and `help` output may be re-configured, for example if you\n prefer to view usage information instead of the summary:\n\n```yml\ntemplates:\n  list: |\n    {{range .Tasks}}  {{cyan .Name}} – {{.Usage}}\n    {{end}}\n```\n\n Or perhaps something more verbose:\n\n```yml\ntemplates:\n  list: |\n    {{range .Tasks}}\n      name: {{cyan .Name}}\n      summary: {{.Summary}}\n      usage: {{.Usage}}\n    {{end}}\n```\n\n## Global tasks\n\n By default `./robo.yml` is loaded, however if you want global tasks\n you can simply alias to something like:\n\n```\nalias segment='robo --config ~/.robo.yml'\n```\n\n## Robo chaining\n\n You can easily use Robo to chain Robo, which is useful\n for multi-environment setups. For example:\n\n```yml\nprod:\n  summary: production tasks\n  exec: robo --config production.yml\n\nstage:\n  summary: stage tasks\n  exec: robo --config stage.yml\n```\n\n Or on remote boxes:\n\n```yml\nprod:\n  summary: production tasks\n  exec: ssh prod-tools -t robo --config production.yml\n\nstage:\n  summary: stage tasks\n  exec: ssh stage-tools -t robo --config stage.yml\n```\n\n  You can also use robo's builtin variables `robo.path`, for example\n  if you put all robofiles in together:\n\n```bash\n├── dev.yml\n├── prod.yml\n├── root.yml\n└── stage.yml\n```\n\n  And you would like to call `dev`, `prod` and `stage` from `root`:\n\n```yml\ndev:\n  summary: Development commands\n  exec: robo --config {{ .robo.path }}/dev.yml\n\nstage:\n  ...\n```\n\n## Composition\n\n  You can compose multiple commands into a single command\n  by utilizing robo's built-in `robo.file` variable:\n\n```yml\none:\n  summary: echo one\n  command: echo one\n\ntwo:\n  summary: echo two\n  command: echo two\n\nall:\n  summary: echo one two\n  command: |\n    robo -c {{ .robo.file }} one\n    robo -c {{ .robo.file }} two\n```\n\n```\n$ robo all\none\ntwo\n```\n\n## Why?\n\n We generally use Makefiles for project specific tasks, however\n the discoverability of global tasks within a large team is\n difficult unless there's good support for self-documentation,\n which Make is bad at.\n\n I'm aware of the million other solutions (Sake, Thor, etc) but\n I just wanted something fast without dependencies.\n\n# License\n\n MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Frobo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj%2Frobo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Frobo/lists"}