0

I would want to create a pull request environment in Azure which gets deployed when a pull request is opened. Users can play around in that environment and find bugs. Once the bugs are fixed, and the PR is closed, I would want to delete that environment.

I am following through Sam Learns Azure and I was able to go through most steps, but its all .NET related.

Does anyone have an idea to do the same for a react-app?

I am also in favor of creating a new slot inside the app-service.

This is my modified code:

jobs:
  - deployment: DeployWebServiceApp
    displayName: "Deploy webservice app"
    environment: ${{parameters.environment}}
    pool:
      vmImage: ubuntu-latest
    strategy:
      runOnce:
        deploy:
          steps:
            - task: DownloadPipelineArtifact@2
              displayName: 'Download Pipeline Artifacts'
              inputs:
                artifactName: "$(Build.BuildId)"
                buildType: 'current'

            - task: AzureCLI@2
              displayName: 'Deploy infrastructure with ARM templates'
              inputs:
                azureSubscription: "${{parameters.serviceConnection}}"
                scriptType: bash
                scriptLocation: inlineScript
                inlineScript: az webapp deployment slot create --name ui-dev-$(prLC)
                  --resource-group rg-dev
                  --slot $(prLC)
                  --configuration-source app-dev
            - task: AzureRmWebAppDeployment@3
              displayName: 'Azure App Service Deploy: web service'
              inputs:
                azureSubscription: "${{parameters.serviceConnection}}"
                appName: "${{parameters.appServiceName}}"
                DeployToSlotFlag: true
                ResourceGroupName: '${{parameters.resourceGroupName}}'
                package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
                RemoveAdditionalFilesFlag: true
                TakeAppOfflineFlag: true
                RenameFilesFlag: true
arunmmanoharan
  • 2,535
  • 2
  • 29
  • 60

1 Answers1

0

Why Not. You can do that in below steps-

  1. Create the Build Pipe which build your react app
  2. In the build pipe set a VSTS var only when it is a PR. eg varPR = x
  3. Create a Release pipe which deploys the app
  4. Add one more task at the end of build pipe to call the release using webhook based on condition varPR = x. Ref - Trigger azure pipeline via webhook?

The link you have shared is also cool that does the job same job in a single build pipe.

Aatif Akhter
  • 2,126
  • 1
  • 25
  • 46