I'm hoping to create a new pipeline that triggers when there is a PR to the "main" branch, and it builds the branch in the PR to see if there are any build issues before we merge it with the "main" branch. I believe the name for this is Build Validation, but I'm stuck with creating the pipeline. Or is this right and I need to handle this with settings in the build validation setup?
I tried to update the YAML so it only runs when a PR is created, I think that part is okay. But I can't seem to figure out how to cancel the deployment part. The changes I make keep breaking in the build process of my existing normal pipeline.
name: Azure Static Web Apps CI/CD
pr:
branches:
include:
- main
trigger: none
jobs:
- job: build_and_deploy_job
displayName: Build and Deploy Job
condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
pool:
vmImage: ubuntu-latest
variables:
- group: Azure-Static-Web-Apps
steps:
- checkout: self
submodules: true
- task: AzureStaticWebApp@0
inputs:
azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS)
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit:
https://aka.ms/swaworkflowconfig
/> app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
env:
NEXT_PUBLIC_OPENAI_KEY: $(NEXT_PUBLIC_OPENAI_KEY)
###### End of Repository/Build Configurations ######