Skip to content

[Breaking] Allow multiple git commands #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 git-subtree
RUN apk add --no-cache git git-subtree
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArnaudRinquin is there not a need for bash here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na, since the entrypoint file changes the shebang to #!/bin/sh


ADD entrypoint.sh /
RUN chmod +x /entrypoint.sh
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -12,6 +12,22 @@ workflow "My build" {

action "git command" {
uses = "srt32/[email protected]"
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/[email protected]"
args = ["status", "show"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great docs updates ;)

}
```
21 changes: 12 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a new line here?