Static site in a CI/CD Pipeline



  • So there are a multitude of tools to use for this but here's what I'll be using:

    • GitLab
    • GitLab CI/CD
    • Asciidoctor

    I prefer Asciidoctor over Markdown because it has standards and different projects aren't implementing their own versions of the tool. A good example of a site is the Groovy documentation site: http://docs.groovy-lang.org/docs/next/html/documentation/

    This is assuming you have a repository created in GitLab and you know how to use Git.

    Let's create our sample Asciidoctor page:

    = Test Site
    [email protected]
    :toc2:
    :sectnums:
    :icons: font
    :experimental: 
    
    == This is a header
    Here's some sample text. It's pretty cool. Enabling experimental lets you use keyboard icons like when you press 
    kbd:[Ctrl + J]
    
    NOTE: This is a test site.
    

    To set up your pipeline, you will need to create a .gitlab-ci.yml file.

    Here's the contents:

    image: asciidoctor/docker-asciidoctor
    
    html:
      script: 
        - asciidoctor site.adoc
      artifacts:
        paths:
          - site.html
    

    Just adding these will allow you to run the CI/CD process on shared runners. This uses the Asciidoctor Docker image to convert that site into an HTML page. It doesn't deploy it anywhere, it's just stored as an artifact in GitLab. However you could deploy to another server or whatever you like.

    I created all of this in a test repository for you to browse. Here's the link https://gitlab.com/hooksie1/test-pipeline-site

    To get the artifact, go to the CI/CD section on the left and click Pipelines. Then you can view that job and it's build step with the artifact.





  • Now anytime you update the .adoc file, GitLab will kickoff the CI/CD process and build the site automatically with the updated content.



  • Ok thanks very much. Going to work on this. Appreciate you putting this out there.



  • @jmoore said in Static site in a CI/CD Pipeline:

    Ok thanks very much. Going to work on this. Appreciate you putting this out there.

    No problem. This is using the shared runners that GitLab offers. You get a certain amount of free time each month on them, otherwise you have to pay. However you can use your own runner (VM or whatever) and that's completely free to tie into their system (and more private since others can't use it).

    If you want to deploy this to a different server you could use your own runner in your environment and then ship the files to the server intead of creating artifacts. But if you want to host the files on GitLab pages the artifacts are a good way to go.



  • @stacksofplates Sounds like a good plan, thanks!


Log in to reply