From 2647030415710ed92da9959c5eed5dd3619559d0 Mon Sep 17 00:00:00 2001 From: Jake Runzer Date: Fri, 2 Oct 2020 22:00:45 +0100 Subject: [PATCH] Run Command (#4) * Add railway run command --- .github/workflows/publish.yml | 6 +++--- cmd/run.go | 7 ++++++- main.go | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5f7d990b6..5e1a9c327 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 diff --git a/cmd/run.go b/cmd/run.go index f3e78517e..11975165f 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -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) diff --git a/main.go b/main.go index 324f12e81..82a15d31e 100644 --- a/main.go +++ b/main.go @@ -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() {