Can GitLab pages be used for review apps on a mkdocs project?

前端 未结 1 1119
挽巷
挽巷 2021-02-10 01:29

This answer by @joki to a previous question suggests that it is possible to deploy each active branch in a GitLab repo to a dynamic environment, by giving browsable artifacts a

1条回答
  •  闹比i
    闹比i (楼主)
    2021-02-10 01:56

    You can see the URL you need in the »Browse« button of the build step in your pipeline.

    Does this work?

    develop:
        artifacts:
            paths:
              - public
    
        environment:
            name: Develop
            url: "https://$CI_PROJECT_NAMESPACE.gitlab.io/-/snim2-test-subgroup/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
    
        script: |
            # whatever
    
        stage: deploy
    
        variables:
            PUBLIC_URL: "/-/snim2-test-subgroup/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public"
    

    You'll also need your change to mkdocs.yml to actually use the PUBLIC_URL, and make sure it's used everywhere that absolute internal links are generated:

    site_url: !!python/object/apply:os.getenv ["PUBLIC_URL"]
    use_directory_urls: false
    …
    

    0 讨论(0)
提交回复
热议问题