Hi all,
I have my Hugo project set up with deployment to s3 via Circleci.
Everything is working fine except for Module Mounts.
Here’s my Circleci config:
version: 2.1
commands:
install_dependencies:
steps:
- restore_cache:
keys:
- node_modules-{{ .Branch }}-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- node_modules-{{ .Branch }}-
- run: sudo apt-get update
- run: sudo apt-get install hugo
- run: sudo apt-get install nodejs
- run: curl -o- -L https://yarnpkg.com/install.sh | bash
- run: echo 'export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"' >> $BASH_ENV
- run: yarn install
- run: sudo apt-get install awscli
- save_cache:
key: node_modules-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ./node_modules
executors:
init:
docker:
- image: circleci/golang:1.12
jobs:
build:
executor: init
steps:
- checkout
- install_dependencies
- run: yarn fetch
- run: yarn build
deploy:
parameters:
deploy_stage:
type: string
default: staging
bucket:
type: string
baseUrl:
type: string
hugoEnvironment:
type: string
default: test
executor: init
steps:
- checkout
- install_dependencies
- run: yarn fetch
- run: yarn build --baseURL <<parameters.baseUrl>> --environment <<parameters.hugoEnvironment>>
- run:
name: Deploy to AWS
command: aws s3 sync ./projectdirectory/public s3://<<parameters.bucket>> --delete --acl public-read
workflows:
build-and-deploy:
jobs:
# Testing to be added in the future
- build
- deploy:
name: deploy-prod
deploy_stage: prod
bucket: projectdirectory-serverless
baseUrl: "https://www-new.myproject.com/"
hugoEnvironment: production
requires:
- build
filters:
branches:
only: master
- deploy:
name: deploy-staging
deploy_stage: staging
bucket: projectdirectory-serverless-staging
hugoEnvironment: test
baseUrl: "https://staging-www-new.myproject.com/"
requires:
- build
filters:
branches:
only: dev
- deploy:
name: deploy-uat
deploy_stage: uat
bucket: projectdirectory-serverless-uat
hugoEnvironment: test
baseUrl: "https://uat-www-new.myproject.com/"
requires:
- build
filters:
branches:
only: uat
The yarn build
command is hugo
.
In my config.toml
I have:
[module]
[[module.mounts]]
source = "assets/theme/assets/svg"
target = "static/theme/assets/svg"
[[module.mounts]]
source = "assets/theme/assets/vendor/font-awesome/webfonts"
target = "static/webfonts"
When I run yarn build
(hugo
) locally, everything builds and the mounted directories in my config.toml are placed into the relevant folders in the site root as expected.
However when Circleci builds, those two folders are missing.
I feel like this is an issue related to Circleci and Go modules, I’m hoping someone with someone can enlighten me.
Thanks in advance.