Skip to content

Fix for workflow failing when there is nothing to commit #3

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

Merged
merged 4 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Check for new commit before trying to push
  • Loading branch information
leigholiver committed Apr 28, 2022
commit a637ac7ba7a220cb8488a5b0e802642be343e1fb
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Action to commit a file/directory to another repo using a deploy key.
* Add the private key to your source repo as a secret

```yaml
uses: leigholiver/commit-with-deploy-key@v1.0.2
uses: leigholiver/commit-with-deploy-key@v1.1.0
with:
source: build_output
destination_folder: dist
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.3
v1.1.0
12 changes: 10 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ elif [ -d $CALLING_DIR/$INPUT_SOURCE ]; then
cp -a $CALLING_DIR/$INPUT_SOURCE/* .
fi

# commit and push
# create the commit
git add .
git commit -m "${INPUT_COMMIT_MESSAGE}"
GIT_SSH_COMMAND=$GIT_SSH git push -u origin $INPUT_DESTINATION_BRANCH

# if there is a new commit - push it to the destination
if [ ! -z "$(git cherry -v)" ]; then
GIT_SSH_COMMAND=$GIT_SSH git push -u origin $INPUT_DESTINATION_BRANCH

# otherwise, don't try to push - this causes the workflow to fail
else
echo "Nothing waiting to be pushed"
fi

# output the commit hash
echo "::set-output name=commit_hash::$(git rev-parse HEAD)"
Expand Down