Skip to content

Commit

Permalink
Run Command (#4)
Browse files Browse the repository at this point in the history
* Add railway run command
  • Loading branch information
coffee-cup authored Oct 2, 2020
1 parent 10c5847 commit 2647030
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Set output
- name: Set version
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Check output
run: echo ${{ steps.vars.outputs.tag }}
- name: Check version
run: echo "Version ${{ steps.vars.outputs.tag }}"

- name: Use Node.js 12
uses: actions/setup-node@v1
Expand Down
7 changes: 6 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ func (h *Handler) Run(ctx context.Context, req *entity.CommandRequest) error {

argsString := ""

// Inject railway envs
for k, v := range *envs {
argsString += fmt.Sprintf("%s=%+v", k, v)
argsString += fmt.Sprintf("%s=%+v ", k, v)
}

for _, arg := range req.Args {
argsString += fmt.Sprintf("%s ", arg)
}

bashCommand := exec.Command("bash", "-c", argsString)
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ func init() {
Short: "Show all your projects",
RunE: contextualize(handler.List),
})
rootCmd.AddCommand(&cobra.Command{
Use: "run",
Short: "Run command inside the Railway environment",
RunE: contextualize(handler.Run),
})
}

func main() {
Expand Down

0 comments on commit 2647030

Please sign in to comment.