简体   繁体   中英

azure static web app, how to have two different web apps (one prod and one non prod) building from the same git repo?

We have two static apps, one for production and one for non production (test). They just show a site down page for when our main site on AEM is down (using traffic manager to switch).

The source is held in an Azure devops git repo.

This is how it is built in non prod:

trigger:
  - main

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      app_location: '/'
      api_location: ''
      output_location: ''
      azure_static_web_apps_api_token: $(deployment_token)

Now we want to make it build a prod version of the static web app, if we push to another branch (eg "prod"). Any idea how we might do this? Not sure how we would differentiate between the prod static web app deployment token and the non prod one either?

Please take a look on this example . Here you have three main steps:

  • in stage Build - a package is being prepared
  • in stage Dev - package is being deployed to Dev env
  • in stage Prod packages is being deployed to Prod env

It is implementation of approach build once deploy many, which is good because it means that on each env you use the same package, so you trully test the package which is going to be deployed to production.

In terms of token, you can put this is two seprate variables group. One name dev, and the other prod. Both should have the same variable deployment_token and then

- stage: Prod
  dependsOn: Dev
  variables:
  - group: Prod

- stage: Dev
  dependsOn: Build
  variables:
  - group: Dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM