Attach workspace from Orb circleci/hugo

I am constructing a pipeline to deploy my Hugo blog hosted on GitHub Pages.

I do this using two repos, one is a private repo that hosts the Hugo source and the other is a public repo that contains the generated static site.

I use git submodules to attach the theme and public site repos to the private repo.

In CircleCI I am using the Orb circleci/hugo to test and build and a custom deploy job.

The Orb provides a feature to use workspace and I wanted to use it to attach the entire checkout directory to the deploy job so that i can use git commands to push the latest build (from the Orb) to the master branch of the static site submodule.

My config.yml looks like this:

      - image: cibuilds/base
    working_directory: /home/circleci
      - run: apk update && apk add git
      - attach_workspace:
          at: project
      - run: git config --global "" && git config --global "CircleCI"
      - run: cd /home/circleci/project/public && git add --all && git commit -m "Automated build and publish site $(date)" && git push origin master
  hugo: circleci/hugo@0.6.0
version: 2.1
      - hugo/build:
          hugo-extra-flags: -t my_theme
          html-proofer: true
          version: latest
      - deploy:
              only: master
            - hugo/build

I got the working directory from the successful output of the hugo/build job:

if [ -e /home/circleci/project/.git ]
  cd /home/circleci/project
  git remote set-url origin "$CIRCLE_REPOSITORY_URL" || true
  mkdir -p /home/circleci/project
  cd /home/circleci/project
  git clone "$CIRCLE_REPOSITORY_URL" .

The Orb docs contains some rather confusing instructions…

The Job source says:

  - when:
      condition: << parameters.persist-to-workspace >>
        - persist_to_workspace:
              - << parameters.destination >>
            root: << parameters.source >>

But the docs says:

persist-to-workspace Whether to persist generated files to a CircleCI Workspace. This uses parameters.source as root and parameters.publishdir as the path.

Also, I don’t know where to put the parameter in the config.yml, is it in the very base structure, as indicated by the above?

But according to the docs:

Parameters are declared by name under a job, command, or executor.

I’ve tried putting it in a few places but I can’t get it working.

The error is in this run step in the deploy job:

#!/bin/bash -eo pipefail cd /home/circleci/project/public && git add --all && git commit -m "Automated build and publish site $(date)" && git push origin master

fatal: not a git repository: /home/circleci/project/public/../.git/modules/public Exited with code exit status 128

CircleCI received exit code 128

Any help or advice would be much appreciated.

Hi @teerakarna! To help us troubleshoot this, can you add a build link where this is failing?

Thank you!

Sorry for delay! Here is the failed build: