我们在 Azure 上使用 Docker 部署了 NextJS 应用程序,我们有 3 个分支:
对于每个新功能,我们创建一个分支
feature
并推送更改。但是,我们希望利益相关者在将其合并到 dev
分支之前看到此功能的实时更改。
在 Vercel 和 Github 中,此功能可用:
这是我们将拉取请求合并到开发分支时的管道:
trigger:
- dev
variables:
dockerRegistryServiceConnection: "xxx"
imageRepository: "xxx"
containerRegistry: "xxx"
dockerfilePath: "$(Build.SourcesDirectory)/Dockerfile.prod"
tag: "$(Build.BuildId)"
vmImageName: "ubuntu-latest"
pool:
vmImage: ubuntu-latest
stages:
- stage: Install
displayName: "Install"
jobs:
- job: InstallJob
displayName: "Install Node.js and Dependencies"
steps:
- task: NodeTool@0
inputs:
versionSpec: "20.x"
displayName: "Install Node.js"
- script: |
npm install
displayName: "Install Node.js and Dependencies"
- stage: UnitComponentTests
displayName: "Run Unit and Component Tests"
jobs:
- job: UnitComponnentTestsJob
displayName: "Run Unit and Component Tests"
steps:
- script: |
npm install
npm run test
displayName: "Run Unit and Component Tests"
- stage: E2ETests
displayName: "Run E2E Tests"
jobs:
- job: E2ETestsJob
displayName: "Run E2E Tests"
steps:
- script: |
npm install
npx playwright install
npm run test-e2e
displayName: "Run E2E Tests"
- stage: Build
displayName: Build
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
buildContext: "./"
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
latest
我希望为每个拉取请求运行相同的文件。合并拉取请求后,应该删除部署实例。
您可以尝试对Build validation
Dev
检查。在此检查中,您可以选择现有管道。
与
Build validation
:
每次创建目标分支为
Dev
的新拉取请求时,Build validation
上设置的管道都会被触发运行该拉取请求。
拉取请求创建后
Active
(不是Abandoned
或Completed
),每次新提交推送到源分支时,新提交都会自动同步到拉取请求,Build validation
上设置的管道将被触发运行拉取请求。