Automated Hugo deployments anywhere using Wercker

Hi @marksouthee
Interesting, this came up for someone else recently as well. I’ve made a note to look into this missing git issue so I can update the tutorial if needed. However, for now at least it’s an easy fix. Adding the following step as the first step in the deploy section should do the trick.

- install-packages:
    packages: git ssh-client

Hi @ArjenSchwarz
In build step it says: ERROR: 2015/11/01 Unable to find static directory for theme hyde-y in /pipeline/source/themes/hyde-y/static
Does your app support git submodules? Because themes/hyde-y in my project is a git submodule.

Hi @GlacJAY,
By default Wercker doesn’t pull in git submodules, so you will have to do that manually. They have a description of how that works in their documentation on http://devcenter.wercker.com/docs/git/submodules.html. If you add the steps they show there before the hugo build step in your wrecker.yml file it should have the submodule included when hugo tries to build the site. I hope that helps, and let me know how you fared.

Yeah it works, except that I removed the add-ssh-key step because of errors. I think it’s optional.

Hi @ArjenSchwarz,
The git ssh -client step has meant the deploy has built successfully. However there are no files in my marksou.github.io repository!

Hi @marksouthee,
Ah, of course, I should have realised that earlier when you mentioned your domain name. The github pages deploy step being used in the tutorial is for project level github pages only. For some strange reason personal github pages (the ones based on your username) work differently. The deployment step did what it’s supposed to do, as there is now a gh-pages branch in your repository.
However, as you need it to be in your other repository you will need to replace the github deployment step with the one below. That should push it to the repository where you want it.
It is possible that you will need to add the git and ssh-client tools again, but I suggest you try it without first.

- leipert/git-push:
     gh_oauth: $GIT_TOKEN
     repo: marksou/marksou.github.io
     branch: master
     basedir: public

Hi @ArjenSchwarz,
I did have to add the git ssh client back in to get it to deploy. I now have a site build in my github pages repo, but the index.html file is empty. I guess there is something else missing?

Hi @marksouthee,
I suspect this will be the last thing :). The issue here isn’t actually with the deployment as I got the same problem when I did a checkout of your code and tried to build it on my local. Your repository is missing most of the files for your theme. You will either need all files from there added to your github repo or add it as a submodule (in which case you can follow the steps detailed in http://devcenter.wercker.com/docs/git/submodules.html to have it pulled in by wercker).

Hi @ArjenSchwarz,
That is very strange, it looks like Git hasn’t committed the contents of the themes\hugo-creative-theme folder within my local repo. Will have to see what has happened. Only thing in my .gitignore is the /public folder!

Hi @ArjenSchwarz,
I decided to start from scratch to get a clean build. The Wercker build is failing at the Hugo Build step. The error message is very long. Shall I post it here or can I email it to you? My repo is marksou/lifecoach

Hi @marksouthee,
Let’s move this over to email :). My email address is visible on my GitHub account https://github.com/ArjenSchwarz

It’s late here now, but I’ll have a look in the morning.

Is there any way to set up this workflow to use a dev version of Hugo? There are features in 1.5dev that we would really like to be able to use, but we are using this as our publish workflow :slight_smile:

Hey @mattstratton, there is actually a feature request for this and I was planning on building support for it over the next week.

Hi @mattstratton, as 0.15 was released last week you might not need it anymore but as of today it is indeed possible to use the latest development version of Hugo by setting the version in the Wercker step to “HEAD”.

Additionally, the step will now use 0.15 as the default version so you can use the released version if you prefer.

1 Like

Actually, we just started getting this error in wercker…

cd $WERCKER_SOURCE_DIR
$ export WERCKER_STEP_ROOT="/wercker/steps/arjen/hugo-build/1.8.0"
$ export WERCKER_STEP_ID="48eaedd8-67c1-4c15-a401-1f24122d12cc"
$ export WERCKER_STEP_NAME="hugo-build"
$ export WERCKER_REPORT_NUMBERS_FILE="$WERCKER_REPORT_DIR/$WERCKER_STEP_ID/numbers.ini"
$ export WERCKER_REPORT_MESSAGE_FILE="$WERCKER_REPORT_DIR/$WERCKER_STEP_ID/message.txt"
$ export WERCKER_REPORT_ARTIFACTS_DIR="$WERCKER_REPORT_DIR/$WERCKER_STEP_ID/artifacts"
$ mkdir -p $WERCKER_REPORT_ARTIFACTS_DIR
$ export WERCKER_STEP_TEMP="/tmp/$WERCKER_STEP_ID"
$ source '/wercker/wercker-build-essentials/init.sh'
$ mkdir -p $WERCKER_STEP_TEMP
$ export WERCKER_HUGO_BUILD_VERSION="0.14"
$ export WERCKER_HUGO_BUILD_THEME="ado"
$ export WERCKER_HUGO_BUILD_FLAGS="--buildDrafts=true"
$ export WERCKER_HUGO_BUILD_DISABLE_PYGMENTS="false"
$ export WERCKER_HUGO_BUILD_FORCE_INSTALL="false"
$ export WERCKER_HUGO_BUILD_PROD_BRANCHES=""
$ export WERCKER_HUGO_BUILD_DEV_BRANCHES=""
$ export WERCKER_HUGO_BUILD_DEV_FLAGS=""
$ export WERCKER_HUGO_BUILD_CONFIG=""
$ source "$WERCKER_STEP_ROOT/run.sh"
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

This is what the wercker.yml looks like:

box: wercker/default
build:
  steps:
    - arjen/hugo-build:
        version: 0.14
        theme: ado
        flags: --buildDrafts=true

deploy:
  steps:
    - lukevivier/gh-pages@0.2.1:
        token: $GIT_TOKEN
        domain: www.arresteddevops.com
        basedir: public
        repo: arresteddevops/arresteddevops.github.io

Same error occurs if we update the hugo version to 0.15 in the config.

FWIW, this happens on another hugo site that was worked just a day ago.

Hmm. Switching to docker seems to have resolved this.

I did have to add

- install-packages:
    packages: git ssh-client

to the deploy stage.

Hi @mattstratton, my apologies for breaking your old setup. The script now installs some more dependencies by default and I hadn’t properly tested it on the non-Docker way of doing things. The step has been fixed now to work there as well, but it’s good to know that you already fixed your own project by changing to the Docker set up.

HI @ArjenSchwarz, I wonder if you’ve had this issue:

It seems like my public folder is being thrown away before the deploy step.

I incorporated an ls step after the build and before the deploy and sure enough, after build public/ contains everything I’d expect. The ls step before deploy shows no public folder at all.

I’m using the docker stack btw.

Any thoughts? My understanding was that wercker was supposed to maintain the output of build for the deploy step.

Here’s my wercker file:

box: debian
build:
  steps:
    - arjen/hugo-build:
        version: "0.15"
        theme: nardocs
        flags: --buildDrafts=true --verbose
    - script:
        name: ls stuff
        code: |
          ls -haltr /pipeline/source/public
deploy: 
  steps:
    - script:
        name: ls stuff
        code: |
          ls -haltr /pipeline/source

here’s the contents of the /pipeline/source/public after build

drwxr-xr-x.  2 root root 4.0K Jan 16 19:01 images
-rw-r--r--.  1 root root    0 Jan 16 19:01 .gitinclude
-rw-r--r--.  1 root root 1.9K Jan 16 19:01 hugo.png
drwxr-xr-x.  2 root root 4.0K Jan 16 19:01 fonts
-rw-r--r--.  1 root root 7.3K Jan 16 19:01 favicon.ico
drwxr-xr-x.  2 root root 4.0K Jan 16 19:01 css
drwxr-xr-x.  2 root root 4.0K Jan 16 19:01 js
drwxr-xr-x.  8 root root 4.0K Jan 16 19:02 ..
drwxr-xr-x.  3 root root 4.0K Jan 16 19:02 minutes
drwxr-xr-x.  2 root root 4.0K Jan 16 19:02 about
drwxr-xr-x.  3 root root 4.0K Jan 16 19:02 subdir_2
drwxr-xr-x.  2 root root 4.0K Jan 16 19:02 glossary
drwxr-xr-x.  2 root root 4.0K Jan 16 19:02 metadocs
drwxr-xr-x.  5 root root 4.0K Jan 16 19:02 subdir_1
drwxr-xr-x.  2 root root 4.0K Jan 16 19:02 style
drwxr-xr-x.  7 root root 4.0K Jan 16 19:02 subdir_3
-rw-r--r--.  1 root root  22K Jan 16 19:02 index.html
-rw-r--r--.  1 root root  31K Jan 16 19:02 index.xml
-rw-r--r--.  1 root root  12K Jan 16 19:02 404.html
-rw-r--r--.  1 root root 1.8K Jan 16 19:02 sitemap.xml
drwxr-xr-x. 14 root root 4.0K Jan 16 19:02 .

now here’s the parent folder during the deploy step:

-rw-r--r--. 1 root root  653 Jan 16 19:02 config.yaml
-rwxr-xr-x. 1 root root  247 Jan 16 19:02 README.md
-rw-r--r--. 1 root root  198 Jan 16 19:02 .gitignore
drwxr-xr-x. 7 root root 4.0K Jan 16 19:02 .git
drwxr-xr-x. 3 root root 4.0K Jan 16 19:02 themes
drwxr-xr-x. 3 root root 4.0K Jan 16 19:02 static
drwxr-xr-x. 3 root root 4.0K Jan 16 19:02 layouts
drwxr-xr-x. 6 root root 4.0K Jan 16 19:02 content
-rw-r--r--. 1 root root  473 Jan 16 19:02 wercker.yml
drwxr-xr-x. 7 root root 4.0K Jan 16 19:02 .
drwxr-xr-x. 7 root root 4.0K Jan 16 19:02 ..

no public folder. weird

Hi @Matt_Reimer, I’m currently having the same problem and on the Wercker Slack I see the same issue being mentioned. It looks like there is an issue with Wercker not passing on the generated code to the deploy step. I don’t know yet if there’s anything we can do about it or if we’ll just have to wait. I’ll let you know once I know more.

Hi @Matt_Reimer, for me it started working again after a while. I hope it was the same for you.