Skip to content

Commit a637ac7

Browse files
committed
Check for new commit before trying to push
1 parent b43b619 commit a637ac7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Action to commit a file/directory to another repo using a deploy key.
77
* Add the private key to your source repo as a secret
88

99
```yaml
10-
uses: leigholiver/commit-with-deploy-key@v1.0.2
10+
uses: leigholiver/commit-with-deploy-key@v1.1.0
1111
with:
1212
source: build_output
1313
destination_folder: dist

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.3
1+
v1.1.0

entrypoint.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@ elif [ -d $CALLING_DIR/$INPUT_SOURCE ]; then
4242
cp -a $CALLING_DIR/$INPUT_SOURCE/* .
4343
fi
4444

45-
# commit and push
45+
# create the commit
4646
git add .
4747
git commit -m "${INPUT_COMMIT_MESSAGE}"
48-
GIT_SSH_COMMAND=$GIT_SSH git push -u origin $INPUT_DESTINATION_BRANCH
48+
49+
# if there is a new commit - push it to the destination
50+
if [ ! -z "$(git cherry -v)" ]; then
51+
GIT_SSH_COMMAND=$GIT_SSH git push -u origin $INPUT_DESTINATION_BRANCH
52+
53+
# otherwise, don't try to push - this causes the workflow to fail
54+
else
55+
echo "Nothing waiting to be pushed"
56+
fi
4957

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

0 commit comments

Comments
 (0)