Created
August 25, 2022 09:54
-
-
Save papeMK2/91477bf1a2df9fee752bc110c9fd20c8 to your computer and use it in GitHub Desktop.
PullRequest With App Service staging slot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
branches: | |
include: | |
- master | |
pr: | |
- master | |
pool: | |
vmImage: ubuntu-latest | |
variables: | |
buildConfiguration: 'Release' | |
workingDirectory: '$(System.DefaultWorkingDirectory)/src/MVCApp/' | |
prId: $(System.PullRequest.PullRequestId) | |
stages: | |
- stage: Build | |
displayName: Build app | |
jobs: | |
- job: Build | |
displayName: Build | |
steps: | |
- task: DotNetCoreCLI@2 | |
displayName: Restore | |
inputs: | |
command: restore | |
projects: $(workingDirectory)/*.csproj | |
- task: DotNetCoreCLI@2 | |
displayName: Build | |
inputs: | |
command: 'build' | |
projects: | | |
$(workingDirectory)/*.csproj | |
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release | |
- task: DotNetCoreCLI@2 | |
displayName: Publish | |
inputs: | |
command: publish | |
publishWebProjects: false | |
projects: $(workingDirectory)/*.csproj | |
arguments: '--configuration Release --output $(System.DefaultWorkingDirectory)/publish' | |
zipAfterPublish: true | |
- publish: '$(System.DefaultWorkingDirectory)/publish' | |
artifact: drop | |
- stage: Create_Slot | |
displayName: Create Pull Request Env | |
dependsOn: Build | |
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) | |
jobs: | |
- job: CreateSlot | |
displayName: CreateSlot | |
steps: | |
- task: AzureCLI@2 | |
inputs: | |
azureSubscription: '{Your Service Connection Name}' | |
scriptType: 'bash' | |
scriptLocation: 'inlineScript' | |
inlineScript: | | |
az deployment group create --resource-group rg-lab --template-file {Bicep file path for create slot} \ | |
--parameters prId=$(prId) \ | |
--parameters appServiceName=app-appservice-lab | |
- download: current | |
artifact: drop | |
- task: AzureRmWebAppDeployment@4 | |
inputs: | |
ConnectionType: 'AzureRM' | |
azureSubscription: '{Your Service Connection Name}' | |
appType: 'webApp' | |
WebAppName: 'app-appservice-lab' | |
deployToSlotOrASE: true | |
ResourceGroupName: 'rg-lab' | |
SlotName: 'pr-$(prId)' | |
packageForLinux: '$(Pipeline.Workspace)/drop/MVCApp.zip' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment