Creating (HTML/PDF) assets for Hugo site with Gitlab CI

Hi!

I’ve created a Gitlab CI job to use pandoc to create some HTML and PDF assets that I would like to deploy to my Hugo site hosted with Gitlab Pages.

In .gitlab-ci.yml my job looks like this:

assets:
  stage: deploy
  image:
    name: pandoc/latex:2.6
    entrypoint: ["/bin/sh", "-c"]
  script:
    - apk add bash
    - apk add zip
    - chmod +x ci-build.sh
    - ./ci-build.sh

However, the assets generated by this job do not seem to be deployed to my site as I get a 404 when trying to access them.

I have tried setting an artifacts path, but get this error:

artifacts:
    paths:
    - public
Uploading artifacts...
WARNING: public: no matching files                 
ERROR: No files to upload 

You can find my repo here and my site here if that helps!

I’d really like to figure this out so that I don’t have to track the assets in Git. Any help would be most appreciated!

My full .gitlab-ci.yml looks like this:

# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry
image: registry.gitlab.com/pages/hugo:latest

variables:
  GIT_SUBMODULE_STRATEGY: recursive

test:
  stage: test
  script:
  - hugo
  except:
  - master

pages:
  stage: deploy
  script:
  - hugo
  artifacts:
    paths:
    - public
  only:
  - master

assets:
  stage: deploy
  artifacts:
    paths:
    - builds/
  image:
    name: pandoc/latex:2.6
    entrypoint: ["/bin/sh", "-c"]
  script:
    - apk add bash
    - apk add zip
    - chmod +x ci-build.sh
    - ./ci-build.sh

I think you’ll get more mileage in the GitLab support channels.

I’m really just looking for info on whether it’s possible to do this. To create more assets and add them to the Hugo site after the fact?

You’d need to either create them before you run Hugo, or use some predictable links and add them to your pre-generated site:

1 Like

Hi @b_rad!

Thanks for your response! I have pre-added the links like this from excerpt from a page:

1. [Reproduction](slides/1-reproduction.html) [(PDF)](pdfs/1-reproduction.pdf)

So any assets generated with Gitlab CI into that directory, I assume, would have been available but I still get a 404 on them.

My latest revision of .gitlab-ci.yml looks like this:

# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry

stages:
  - test
  - deploy
  - assets

variables:
  GIT_SUBMODULE_STRATEGY: recursive

test:
  image: registry.gitlab.com/pages/hugo:latest
  stage: test
  script:
  - hugo
  except:
  - master

assets:
  stage: assets
  image:
    name: pandoc/latex:2.6
    entrypoint: ["/bin/sh", "-c"]
  before_script:
    - apk add bash
    - apk add zip
    - chmod +x ci-build.sh
  script:
    - ./ci-build.sh
  artifacts:
    paths:
    - public

pages:
  image: registry.gitlab.com/pages/hugo:latest
  stage: deploy
  script:
  - hugo
  artifacts:
    paths:
    - public
  only:
  - master

And I get this response from the job, yet the assets are not visible:

Uploading artifacts...
public: found 383 matching files                   
Uploading artifacts to coordinator... ok            id=284938060 responseStatus=201 Created token=hVA-17eX
Job succeeded

@finnlesueur Sorry, I haven’t had time to debug this further. Where you able to solve it?