Skip to content

Commit

Permalink
Don't attempt to commit changes if there are none.
Browse files Browse the repository at this point in the history
  • Loading branch information
DevinCarr committed Jan 22, 2019
1 parent 565ca2c commit 5ca1a9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ action "Publish" {
- `GIT_EMAIL`: Github email of the commiter.

### Environment Variables

- `PUBLISH_DIRECTORY`: The action will copy all of the files from this directory into the root of the `gh-pages` branch.


22 changes: 18 additions & 4 deletions publish-to-gh-pages
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,34 @@ main(){

git clone $repo_url $repo
cd $repo
# Set the commit user details
git config user.name "$GIT_USER"
git config user.email "$GIT_EMAIL"
git config remote.origin.url $repo_url

# Get the repository's gh-pages branch
git fetch origin gh-pages
git checkout gh-pages
# Remove the current files
git rm --ignore-unmatch -rf .
echo "Copy over files from $build_files"
cp -r $build_files .
ls -al
git add .
git status
git commit -m "Published via Github Action."
git status
git push -u origin gh-pages

# Check to see if the number of changes is 0
changes=$(git status --short | wc -l)
if [[ "$changes" -eq "0" ]]; then
# Don't commit a change if no changes to be made
echo "No changes from current published build, exiting."
else
# Commit the current changes and push
git add .
git commit -m "Published via Github Action."
git status
git push -u origin gh-pages
fi

# Clean up
cd ..
rm -rf $repo
Expand Down

0 comments on commit 5ca1a9e

Please sign in to comment.