Warm tip: This article is reproduced from stackoverflow.com, please click
gitlab gitlab-ci reveal.js gitlab-pages

GitLab CI: deploy multiple reveal.js presentations from one repository

发布于 2020-04-11 22:44:11

This question is about how to deploy multiple reveal.js presentations on GitLab pages, originating from one repository.

Summary

I'm quite new to reveal.js and playing around with integration to GitLab, deploying a presentation to GitLab pages. In my repo, I'm hosting my themes and presentations (all in one repo). I can deploy one presentation from one branch. Next goal is to host all/multiple (public) presentations at the same time with GitLab pages.

Setup

  • In my repository each presentation (reveal.js from here) is sitting in one branch. There are also theme based branches that are just for keeping the record. For the example assume there are two presentations, sitting in /2020/pres1 and /2020/pres2. (Setup was adapted from Elmiko ).
  • In the first presentation branch, a .gitlab-ci.yml file is sitting, which is deploying the first presentation to username.gitlab.io/repo-name/ This is working fine.

    .gitlab-ci.yml:

pages:
  stage: deploy
  script:
  - mkdir .public
  - cp -r * .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - 2020/pres1
  • To my understanding, adding a second, identical file, adapted for pres2 it the 2020/pres2 branch would 'overwrite' the deployed first page.

Question

What alterations have to be made on the yml files to achieve the following result?

  • Presentations are hosted at username.gitlab.io/repo-name/year/branch.
  • In this example the presentations would be reached at:
    • username.gitlab.io/repo-name/2020/pres1 and
    • username.gitlab.io/repo-name/2020/pres2

Thanks in advance for your advice.

Questioner
Laenan
Viewed
43
Laenan 2020-02-03 05:04

With some trail and error, I came up with the following solution:

cache:
  paths:
    - public

pages:
  stage: deploy

  script:
  - mkdir .build
  - cp -r * .build/
  - mkdir -p public/$CI_COMMIT_BRANCH/
  - rm -r public/$CI_COMMIT_BRANCH/* # do delete possible stuff from old build
  - mv .build/* public/$CI_COMMIT_BRANCH/
  artifacts:
    name: "$CI_COMMIT_BRANCH"
    paths:
    - public

This post helped to develop the solution shown. Comments on possible flaws of this solution are appreciated. Not sure if it is a problem that the only statement was removed.