From 0d1df88dde9164e7cfcfb5f85e040e944ec1fea5 Mon Sep 17 00:00:00 2001 From: Arnaud Rinquin Date: Mon, 18 Feb 2019 13:54:53 +0100 Subject: [PATCH] Allow multiple git commands --- Dockerfile | 2 +- README.md | 20 ++++++++++++++++++-- entrypoint.sh | 21 ++++++++++++--------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index c505861..4176ad0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ LABEL "com.github.actions.color"="yellow" LABEL "repository"="http://github.com/srt32/git-actions" LABEL "homepage"="http://github.com/srt32/git-actions" -RUN apk add --no-cache git bash +RUN apk add --no-cache git ADD entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/README.md b/README.md index 05b1e20..7fd66c5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GitHub Action for running git commands -You can run any `git` command you need. For example, you could run `git status` like this. +You can run any `git` commands you need. For example, you could run `git status` like this. ```hcl workflow "My build" { @@ -12,6 +12,22 @@ workflow "My build" { action "git command" { uses = "srt32/git-actions@v0.0.3" - args = "git status" + args = ["status"] +} +``` + +You can also run multiple git commands like so: + +```hcl +workflow "My build" { + resolves = [ + "git command", + ] + on = "push" +} + +action "git command" { + uses = "srt32/git-actions@v0.0.3" + args = ["status", "show"] } ``` diff --git a/entrypoint.sh b/entrypoint.sh index 513844c..3e7501b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,13 @@ -#!/bin/bash -set -e +#!/bin/sh -echo "#################################################" -echo "Starting the git Action" - -sh -c "$*" - -echo "#################################################" -echo "Completed the git Action" +for cmd in "$@"; do + echo "Running 'git $cmd'..." + if sh -c "git $cmd"; then + # no op + echo "Successfully ran 'git $cmd'" + else + exit_code=$? + echo "Failure running 'git $cmd', exited with $exit_code" + exit $exit_code + fi +done \ No newline at end of file