Skip to content
Permalink
Browse files

Better deploy script example

The given deploy script example was not very robust, if cd fails then it would update the current git repository etc

I've also improved the portability by changing the shebang to `#!/bin/sh` and used `printf` instead of `echo` (in posix sh echo with arguments is undefined)
  • Loading branch information...
UlisseMini authored and bep committed Jul 19, 2019
1 parent 540aedd commit 41aae7abb37d43db3a38e09f2ef674cce2c98ce9
Showing with 9 additions and 8 deletions.
  1. +9 −8 content/en/hosting-and-deployment/hosting-on-github.md
@@ -67,30 +67,31 @@ You're almost done. In order to automate next steps create a `deploy.sh` script.
The following are the contents of the `deploy.sh` script:

```
#!/bin/bash
#!/bin/sh
# If a command fails then the deploy stops
set -e
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"
# Build the project.
hugo # if using a theme, replace with `hugo -t <YOURTHEME>`
# Go To Public folder
cd public
# Add changes to git.
git add .
# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
then msg="$1"
msg="rebuilding site $(date)"
if [ -n "$*" ]; then
msg="$*"
fi
git commit -m "$msg"
# Push source and build repos.
git push origin master
# Come Back up to the Project Root
cd ..
```


0 comments on commit 41aae7a

Please sign in to comment.
You can’t perform that action at this time.