better/prettier error handling on deploy

This commit is contained in:
Jeppe Ernst 2018-04-17 23:40:25 +02:00
parent 9fdd1c77f8
commit d702e9d484
5 changed files with 37 additions and 12 deletions

View File

@ -6,9 +6,6 @@
You need docker-compose. Simply run
`docker-compose up` to launch the site in a docker container with livereload support.
## Deploy to FTP with Docker
Make sure that you have created a file in `_scripts/` called `config.sh`, protip: just duplicate the `config-example.sh` file, and set the correct values, you should only need to change username and password. Then you can build the site ande deploy if by running `docker-compose -f docker-compose-deploy.yml up`
### Or install Jekyll locally
#### Install Jekyll and Bundler gems through RubyGems
@ -24,7 +21,10 @@ You can now see the site at [localhost:4000](http://localhost:4000)
## Deploy
It's **important** that you build the site with `JEKYLL_ENV=production bundle exec jekyll build` before deploying the contents of the `_site` directory. We're doing some debugging stuff when then project is build in the development env.
If not using Docker, it's **important** that you build the site with `JEKYLL_ENV=production bundle exec jekyll build` before deploying the contents of the `_site` directory. We're doing some debugging stuff when the project is build in the development env.
### Deploy to FTP with Docker
Make sure that you have created a file in `_scripts/` called `config.sh`, (protip: just duplicate the `config-example.sh` file, and set the correct values, you should only need to change username and password.) Then you can build the site ande deploy it by running `docker-compose -f docker-compose-deploy.yml up`
## Structure
The contents of the index page is defined in the frontmatter of the file `index.md`
The contents of the index pages is defined in the frontmatter of the files `_pages/index-<language>.md`

View File

@ -20,6 +20,9 @@ description: >- # this means to ignore newlines until "baseurl:"
Nu gør vi noget ved det! #ulovligLogning
baseurl: "" # the subpath of your site, e.g. /blog
url: "https://ulovliglogning.dk" # the base hostname & protocol for your site, e.g. http://example.com
donationCounter:
donated: 110000
goal: 250000
# multilanguage support
languages: ["da", "en"]
@ -30,7 +33,7 @@ parallel_localization: false
# Build settings
permalink: /:title/
markdown: kramdown
exclude: ["README.md", 'Gemfile.lock', 'Gemfile', "docker-compose.yml"]
exclude: ["README.md", 'Gemfile.lock', 'Gemfile', "docker-compose*.yml"]
include: ["_pages"]
plugins:
- jekyll-feed

View File

@ -1,13 +1,35 @@
#!/bin/sh
set -e
#!/bin/bash
error="\033[0;31m"
success="\033[0;32m"
normal="\033[0m"
#get config vars
source _scripts/config.sh
if [[ -z $jekyll_dir || -z $remote_username || -z $remote_password || -z $remote_host || -z $remote_dir ]]; then
echo -e "${error}FAILED: You have ommited one or more values from the config file, see the 'config-example.sh' file for the required values.${normal}"
exit 1
fi
echo -e "${success}Starting build…${normal}"
#Disable SSL check for lftp, this fails on our host :(
echo "set ssl:verify-certificate no" > ~/.lftprc
if [ -d "$jekyll_dir" ]; then
jekyll build
lftp -u ${remote_username},${remote_password} -e "mirror -R -p -P=10 --ignore-time -v ${jekyll_dir}/_site/ ${remote_dir};quit" ftp://${remote_host}
jekyll build --strict_front_matter
if [[ $? != 0 ]]; then
echo -e "${error}FAILED: DID NOT DEPLOY!${normal}"
exit 1
else
echo -e "${success}Build succeded, now uploading to FTP server${normal}"
lftp -u ${remote_username},${remote_password} -e "mirror -R -p -P=10 --ignore-time -v ${jekyll_dir}/_site/ ${remote_dir};quit" ftp://${remote_host}
if [[ $? != 0 ]]; then
echo -e "${error}FAILED: Something went wrong trying to upload to the FTP server${normal}"
exit 1
else
echo -e "${success}FTP upload complete, deployment DONE!${normal}"
fi
fi
fi

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
jekyll_dir="/srv/jekyll"
remote_host="ulovliglogning.dk"

View File

@ -1,7 +1,7 @@
jekyll:
image: jekyll/builder
command: sh /srv/jekyll/_scripts/build-then-deploy.sh
command: bash /srv/jekyll/_scripts/build-then-deploy.sh
ports:
- 4000:4000
volumes: