Once we connect our Azure static web app to the code on GitHub, staging environments are automatically created when a pull request is issued for the main branch (aka master). That part is working fine.
However, I'd like to create staging environments when a pull request is issued for a different branch. Here's the basic idea of a branching scheme to be used for that workflow:
-
main: production
-
dev: staging / integration environment
-
feature-[XYZ]: new features
So, for example, I want to create a staging environment in my Azure static web app when a pull request is issued for the dev branch.
I have not found an example of how to accomplish this. One thing I tried was to add the dev branch in the list of branches in the workflow action file like this:
on:
push:
branches:
- main #
- dev # <-- I added this one
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main #
- dev # <-- I added this one
jobs:
build_and_deploy_job:
# (other normal stuff here - removed for brevity)
While that change did create a deployment to my Azure static web app for the dev branch, it also made my main branch deployment use the dev branch's code.
The Azure overview page also confirms that it now uses the dev branch for production:
What is the proper way to accomplish my goal?