如何在DevOps中部署HTML文档页面?

huangapple go评论57阅读模式
英文:

how to deploy an html documentation page in devOps?

问题

我的DevOps管道正在构建我的Python库的文档。这些文档是使用Sphinx构建的,因此我将整个docs/_build文件夹导出为一个构建产物,但我不知道如何将其部署为文档网站。

这是我的doc.yaml文件:

trigger:
  branches:
    include:
      - main

pool:
  vmImage: windows-latest

steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: "3.10"
    displayName: "使用Python 3.10"

  - script: python -m pip install nox
    displayName: "安装依赖项"

  - script: nox -s docs
    displayName: "构建静态文档"

  - task: PublishBuildArtifacts@1
    displayName: "发布HTML"
    inputs:
      pathToPublish: "./docs/_build/html/"
      artifactName: "documentation"

请注意,这是一个静态网站构建。

英文:

My devOps pipeline is building the documentation of my python lib. This documentation is built with Sphinx so I export the whole docs/_build folder as an artifact but I don't know how to deploy it as a documentation website.

Here is my doc.yaml:

trigger:
  branches:
    include:
      - main

pool:
  vmImage: windows-latest

steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: "3.10"
    displayName: "Use Python 3.10"

  - script: python -m pip install nox
    displayName: "Install dependencies"

  - script: nox -s docs
    displayName: "Build static docs"

  - task: PublishBuildArtifacts@1
    displayName: "Publish HTML"
    inputs:
      pathToPublish: "./docs/_build/html/"
      artifactName: "documentation"

Note that the build is a static website.

答案1

得分: 1

准备静态 Web 应用程序

部署静态资源的第一步是创建将要部署文件的 Web 应用程序。

要创建静态 Web 应用程序,请首先访问 Azure 门户:https://portal.azure.com/

请按照这个中等文章中的说明操作,因为该过程没有自动化,需要点击多个按钮。您还可以参考这个答案](https://stackoverflow.com/questions/76631775/how-to-deploy-as-a-web-app-the-html-static-website-generated-by-pytest-in-devops/76632987#76632987) 上写下的说明。

一旦您的静态应用程序准备好了,请保存令牌。

创建文档

无需创建一个 artifact,因为您使用相同的流水线来构建和发布。只需运行您喜欢的 Sphinx 构建命令:

- script: make html # 可以包装在 nox 中,或直接使用 stb
  displayName: "构建静态文档"

如果您遵循了 Sphinx-quickstart 的约定,文档应该位于 docs/_build/html。创建一个额外的步骤来将此文件夹发送到应用程序:

- task: AzureStaticWebApp@0
    inputs:
      app_location: "/docs/_build/html"
      azure_static_web_apps_api_token: $(DEPLOYMENT_TOKEN)

不要忘记在流水线变量中添加之前保存的 DEPLOYMENT_TOKEN。运行流水线,文档将在 Azure 应用程序中可用。

英文:

Prepare the static webApp

The first step to deploy your static resource is to create the web application where the files will be deployed.

To create a static web App, first go to the Azure portal: https://portal.azure.com/

Please follow the instruction from this medium article as the process is not automated at all an require to click on multiple buttons. You can also refer to this answer](https://stackoverflow.com/questions/76631775/how-to-deploy-as-a-web-app-the-html-static-website-generated-by-pytest-in-devops/76632987#76632987) were instruction have been written down.

Once your static app is ready, save the token.

Create the documentation

No need to create an artifcat as you use the same pipeline to build and publish. Simply run your favorit sphinx build command:

- script: make html # it can be wrapped in nox or directly use stb
  displayName: "Build static docs"

If you respected the convention from Sphinx-quickstart, the documentation should be located in docs/_build/html. Create a extra step to send this folder to the application:

- task: AzureStaticWebApp@0
    inputs:
      app_location: "/docs/_build/html"
      azure_static_web_apps_api_token: $(DEPLOYMENT_TOKEN)

Don't forget to add the DEPLOYMENT_TOKEN that we saved earlier in the pipeline variable. Run the pipeline and the documentation will be available in the Azure app.

huangapple
  • 本文由 发表于 2023年7月7日 03:03:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76631840.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定