Coming from github, how to get gitlab pages to work

I am a new arrival to gitlab, coming from github after the microsoft take-over.

I have several repo’s which use the github.io github pages feature.

I have tried to get the gitlab version to work and sadly, just can’t seem to understand what to put in the:

.gitlab-ci.yml file

My example repo is:

gratefulfrog/Btest

The configuration after import seems ok. My goal is to create a pipeline that will create the static web page from the gh-pages branch, using the file:

index.html 

as root.

My current .gitlab-ci.yml fails with pages:deploy - missing pages artefacts. The content of the file is below.

Any help would be great - sorry for such a noobie question!
Bob

pages:
  stage: deploy
  script:
  - echo 'Nothing to do at all...'
  artifacts:
  only:
  - gh-pages
  - master

Hi! For the pages to work, you need to have a public directory present when the pipeline runs. Here’s what you can try:

pages:
  stage: deploy
  script:
  - mkdir public
  - cp index.html public/
  artifacts:
    paths:
    - public
  only:
  - gh-pages

Then add and commit this in the gh-pages branch (not master).

Here are some links that might help you:

@axil Thank you for your help.

Sadly, your suggestion cannot work because simply copying index.html is not enough. The entire branch needs to be copied to public!

After lots of trial and error, I was able to produce the following code which I hope will work for all my github imported projects:

pages:
  stage: deploy
  script:
  - mkdir .public
  - cp -r * .public
  - mv .public public
  - echo "created public dir for html pages"
  artifacts:
    paths:
    - public
  only:
  - gh-pages

It worked on my test project “Ctest” at least!

Thank you for your help! I hope this is the last issue I face in the migration.

I would suggest that you share this advice more generally since many people will face the same issues as they come in from Github…

Cheers,
Bob

Hello Bob,

maybe you could create the content directly in the folder public? Then no move is needed anymore.

Regards
Mirko

Thanks for the suggestion, but the use of the script as above works perfectly and does not require any re-organisation of the code.

Cheers,
B

Hello, this was more of a generic hint. On github you needed to store stuff in a gh-pages branch, with GitLab you just call your doc creator and tell GitLab to create an artifact (there might even be separate ones for docs and other deliverables)