-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2808e3e
commit fdb9af2
Showing
5 changed files
with
126 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
# tci | ||
CI in your terminal | ||
Deploys in your terminal. Describe deployment steps in YAML file and run them from terminal using `tci deploy` command. | ||
|
||
Features: | ||
- describe deployment steps in YAML file | ||
- enjoy colored output :) | ||
|
||
Step types: | ||
- terminal command | ||
- cycles with conditions, retries and delays | ||
- defer commands, which will run in the end of deploy even if it failed | ||
|
||
## Install | ||
|
||
|
||
## Usage | ||
- Create `tci.yml` file. Example: | ||
```yml | ||
steps: | ||
# run `ls -a` | ||
- mode: cmd | ||
command: ls -a | ||
|
||
# default mode is `cmd` so you can omit it | ||
- command: ls | ||
|
||
# the defer step will be executed in the end of deploy no matter what | ||
- mode: defer | ||
command: echo q | ||
|
||
# Run `date +%s` maximum 5 times with 1s delay between retries until output contains `99` | ||
- mode: until | ||
command: date +%s | ||
contains: 99 | ||
retries: 5 # default value is 3 | ||
delay: 1000 # default value is 100 | ||
``` | ||
- Run `tci deploy` or `tci d` to run `tci.yml` file | ||
- To run another file use `--file` or `-f` flag. Example: `tci -f deploy.yml d` | ||
|
||
## Real Example | ||
|
||
## Help | ||
- Run `tci` or `tci help` | ||
|
||
## Roadmap | ||
- add `run: always` | ||
- add readme | ||
- add real example to readme | ||
- release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package steps | ||
|
||
import ( | ||
"strings" | ||
"os/exec" | ||
"github.com/sergey-koba-mobidev/tci/utils" | ||
"errors" | ||
) | ||
|
||
type DeferStep struct { | ||
step utils.Step | ||
} | ||
|
||
func (c DeferStep) run() ([]byte, error) { | ||
if c.step.Command == "" { | ||
return nil, errors.New("`command` cannot be blank for defer step") | ||
} | ||
|
||
parts := strings.Fields(c.step.Command) | ||
head := parts[0] | ||
parts = parts[1:len(parts)] | ||
|
||
out, err := exec.Command(head, parts...).Output() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return out, nil | ||
} | ||
|
||
func (c DeferStep) name() string { | ||
return c.step.Command | ||
} | ||
|
||
func (c DeferStep) setStep(s utils.Step) StepInterface { | ||
c.step = s | ||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters