Skip to content

Commit 21fdf6f

Browse files
authored
Merge pull request #196262 from simonaco/swa/devops-previews
Swa/devops-previews
2 parents 373c69f + ffc01d9 commit 21fdf6f

File tree

4 files changed

+116
-4
lines changed

4 files changed

+116
-4
lines changed

articles/static-web-apps/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
href: review-publish-pull-requests.md
5858
- name: Branch environments
5959
href: branch-environments.md
60+
- name: Named environments
61+
href: named-environments.md
6062
- name: Custom domains
6163
items:
6264
- name: About custom domains

articles/static-web-apps/branch-environments.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ You can configure your site to deploy every change made to branches that aren't
1717

1818
To enable stable URL environments, make the following changes to your [configuration file](configuration.md).
1919

20-
- Set the `production_branch` input on the `static-web-apps-deploy` GitHub action to your production branch name. This ensures changes to your production branch are deployed to the production environment, while changes to other branches are deployed to a preview environment.
21-
- List the branches you want to deploy to preview environments in the `on > push > branches` array in your workflow configuration so that changes to those branches also trigger the GitHub Actions deployment.
22-
- Set this array to `**` if you want to track all branches.
20+
- Set the `production_branch` input to your production branch name on the `static-web-apps-deploy` job in GitHub action or on the AzureStaticWebApp task. This ensures changes to your production branch are deployed to the production environment, while changes to other branches are deployed to a preview environment.
21+
- List the branches you want to deploy to preview environments in the trigger array in your workflow configuration so that changes to those branches also trigger the GitHub Actions or Azure Pipelines deployment.
22+
- Set this array to `**` for GitHub Actions or `*` for Azure Pipelines if you want to track all branches.
2323

2424
## Example
2525

2626
The following example demonstrates how to enable branch preview environments.
2727

28+
# [GitHub Actions](#tab/github-actions)
29+
2830
```yml
2931
name: Azure Static Web Apps CI/CD
3032

@@ -54,6 +56,27 @@ jobs:
5456
...
5557
production_branch: "main"
5658
```
59+
# [Azure Pipelines](#tab/azure-devops)
60+
61+
```yml
62+
trigger:
63+
- main
64+
- dev
65+
- staging
66+
67+
pool:
68+
vmImage: ubuntu-latest
69+
70+
steps:
71+
- checkout: self
72+
submodules: true
73+
- task: AzureStaticWebApp@0
74+
inputs:
75+
...
76+
production_branch: 'main'
77+
```
78+
79+
---
5780
5881
> [!NOTE]
5982
> The `...` denotes code skipped for clarity.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Create named preview environments in Azure Static Web Apps
3+
description: Expose stable URLs for named environments to evaluate changes in Azure Static Web Apps
4+
author: craigshoemaker
5+
ms.author: cshoe
6+
ms.service: static-web-apps
7+
ms.topic: conceptual
8+
ms.date: 04/27/2022
9+
ms.custom: template-how-to
10+
---
11+
12+
# Create named preview environments in Azure Static Web Apps
13+
14+
You can configure your site to deploy every change to a named environment. This preview deployment is published at a stable URL that includes the environment name. For example, if the environment is named `release`, then the preview is available at a location like `<DEFAULT_HOST_NAME>-release.<LOCATION>.azurestaticapps.net`.
15+
16+
## Configuration
17+
18+
To enable stable URL environments with named deployment environment, make the following changes to your [configuration file](configuration.md).
19+
20+
- Set the `deployment_environment` input to a specific name on the `static-web-apps-deploy` job in GitHub action or on the AzureStaticWebApp task. This ensures all changes to your tracked branches are deployed to the named preview environment.
21+
- List the branches you want to deploy to preview environments in the trigger array in your workflow configuration so that changes to those branches also trigger the GitHub Actions or Azure Pipelines deployment.
22+
- Set this array to `**` for GitHub Actions or `*` for Azure Pipelines if you want to track all branches.
23+
24+
## Example
25+
26+
The following example demonstrates how to enable branch preview environments.
27+
28+
# [GitHub Actions](#tab/github-actions)
29+
30+
```yml
31+
name: Azure Static Web Apps CI/CD
32+
33+
on:
34+
push:
35+
branches:
36+
- "**"
37+
pull_request:
38+
types: [opened, synchronize, reopened, closed]
39+
branches:
40+
- main
41+
42+
jobs:
43+
build_and_deploy_job:
44+
...
45+
name: Build and Deploy Job
46+
steps:
47+
- uses: actions/checkout@v2
48+
with:
49+
submodules: true
50+
- name: Build And Deploy
51+
id: builddeploy
52+
uses: Azure/static-web-apps-deploy@v1
53+
with:
54+
...
55+
deployment_environment: "release"
56+
```
57+
# [Azure Pipelines](#tab/azure-devops)
58+
59+
```yml
60+
trigger:
61+
- "*"
62+
63+
pool:
64+
vmImage: ubuntu-latest
65+
66+
steps:
67+
- checkout: self
68+
submodules: true
69+
- task: AzureStaticWebApp@0
70+
inputs:
71+
...
72+
deployment_environment: "release"
73+
```
74+
75+
---
76+
77+
> [!NOTE]
78+
> The `...` denotes code skipped for clarity.
79+
80+
In this example, changes to all branches will be deployed to the `release` named preview environment.
81+
82+
## Next Steps
83+
84+
> [!div class="nextstepaction"]
85+
> [Review pull requests in pre-production environments](./review-publish-pull-requests.md)

articles/static-web-apps/preview-environments.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ The following deployment types are available in Azure Static Web Apps.
2727

2828
- [**Pull requests**](review-publish-pull-requests.md): Pull requests against your production branch deploy to a temporary environment that disappears after the pull request is closed. The URL for this environment includes the PR number as a suffix. For example, if you make your first PR, the preview location looks something like `<DEFAULT_HOST_NAME>-1.<LOCATION>.azurestaticapps.net`.
2929

30-
- [**Branch**](branch-environments.md): You can optionally configure your site to deploy every change made to branches that aren't a production branch. This preview deployment lives for the entire lifetime of the branch and is published at a stable URL that includes the branch name. For example, if the branch is named `dev`, then the environment is available at a location like `<DEFAULT_HOST_NAME>-dev.<LOCATION>.azurestaticapps.net`.
30+
- [**Branch**](branch-environments.md): You can optionally configure your site to deploy every change made to branches that aren't a production branch. This preview deployment is published at a stable URL that includes the branch name. For example, if the branch is named `dev`, then the environment is available at a location like `<DEFAULT_HOST_NAME>-dev.<LOCATION>.azurestaticapps.net`.
31+
32+
- [**Named environment**](named-environments.md): You can configure your pipeline to deploy all changes to a named environment. This preview deployment is published at a stable URL that includes the environment name. For example, if the deployment environment is named `release`, then the environment is available at a location like `<DEFAULT_HOST_NAME>-release.<LOCATION>.azurestaticapps.net`.
3133

3234
## Next Steps
3335

0 commit comments

Comments
 (0)