Azure DevOps Repo 到 Azure 静态 HTML CI/CD 管道

Azure DevOps Repo to Azure Static HTML CI/CD Pipeline

我使用静态 HTML 功能在 Azure 存储中托管了一个静态 HTML 网站。我正在使用 Azure DevOps Git Repo 作为我的源代码控制。

目前我正在手动推送已更改的文件 Azure 存储,但希望自动执行该任务。触发器将在主分支更新时更新,然后它应该更新 Azure 存储帐户($web 文件夹)。

我正在查看 Pipelines 并开始使用向导并选择了我的 repo。我看到 "Configure your pipeline" 的第一个选项称为 HTML - 存档静态 HTML 项目并将其与构建记录一起保存。

它生成这个 YAML:

# HTML
# Archive your static HTML project and save it with the build record.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(build.sourcesDirectory)'
    includeRootFolder: false
- task: PublishBuildArtifacts@1

问题:

  1. 这是完成我想要做的事情的正确模板吗?如果是,我需要做什么 add/modify 才能实现我的目标?
  2. 还有其他方法可以实现我的目标吗?

你走在正确的道路上。您需要将您的输入更新为类似于:

inputs:
rootFolderOrFile: ‘$(Build.SourcesDirectory)/dist’
archiveType: ‘zip’
archiveFile: ‘$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip’
replaceExistingArchive: true

还有一个博客可供您参考:

https://medium.com/@matthewleak/deploying-a-static-website-to-azure-storage-using-azure-devops-fa0bed457d07