ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Static site in a CI/CD Pipeline

    IT Discussion
    2
    6
    872
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates
      last edited by

      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.

      1 Reply Last reply Reply Quote 6
      • stacksofplatesS
        stacksofplates
        last edited by

        Here's a direct link to the artifact : https://hooksie1.gitlab.io/-/test-pipeline-site/-/jobs/168166600/artifacts/site.html

        1 Reply Last reply Reply Quote 1
        • stacksofplatesS
          stacksofplates
          last edited by

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

          1 Reply Last reply Reply Quote 1
          • jmooreJ
            jmoore
            last edited by

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

            stacksofplatesS 1 Reply Last reply Reply Quote 2
            • stacksofplatesS
              stacksofplates @jmoore
              last edited by

              @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.

              jmooreJ 1 Reply Last reply Reply Quote 0
              • jmooreJ
                jmoore @stacksofplates
                last edited by

                @stacksofplates Sounds like a good plan, thanks!

                1 Reply Last reply Reply Quote 1
                • 1 / 1
                • First post
                  Last post