|
1 | 1 | ---
|
2 |
| -title: Create stable URLs for preview environments in Azure Static Web Apps |
3 |
| -description: Expose stable URLs for specific branches or environment to evaluate changes in Azure Static Web Apps |
| 2 | +title: Preview environments in Azure Static Web Apps |
| 3 | +description: Expose preview environments to evaluate changes in Azure Static Web Apps |
4 | 4 | author: craigshoemaker
|
5 | 5 | ms.author: cshoe
|
6 | 6 | ms.service: static-web-apps
|
7 |
| -ms.topic: how-to |
| 7 | +ms.topic: conceptual |
8 | 8 | ms.date: 03/29/2022
|
9 | 9 | ms.custom: template-how-to
|
10 | 10 | ---
|
11 | 11 |
|
12 |
| -# Create stable URLs for preview environments in Azure Static Web Apps |
| 12 | +# Preview environments in Azure Static Web Apps |
13 | 13 |
|
14 |
| -By default, when you deploy a site to Azure Static Web Apps [each pull request deploys a preview version of your site available through a temporary URL](review-publish-pull-requests.md). This version of the site allows you to review changes before merging pull requests. Once the pull request is closed, the temporary environment disappears. |
| 14 | +By default, when you deploy a site to Azure Static Web Apps [each pull request deploys a preview version of your site available through a temporary URL](review-publish-pull-requests.md). This version of the site allows you to review changes before merging pull requests. Once the pull request (PR) is closed, the temporary environment disappears. |
15 | 15 |
|
16 | 16 | Beyond PR-driven temporary environments, you can enable preview environments that feature stable locations. The URLs for preview environments take on the following form:
|
17 | 17 |
|
18 | 18 | ```text
|
19 | 19 | <DEFAULT_HOST_NAME>-<BRANCH_OR_ENVIRONMENT_NAME>.<LOCATION>.azurestaticapps.net
|
20 | 20 | ```
|
21 | 21 |
|
22 |
| -This article demonstrates how to enable preview environments in GitHub. |
23 |
| - |
24 | 22 | ## Deployment types
|
25 | 23 |
|
26 | 24 | The following deployment types are available in Azure Static Web Apps.
|
27 | 25 |
|
28 | 26 | - **Production**: Changes to production branches are deployed into the production environment. Your custom domain points to this environment, and content served from this location is indexed by search engines.
|
29 | 27 |
|
30 |
| -- **PR**: 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`. |
31 |
| - |
32 |
| -- **Branch**: 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`. |
33 |
| - |
34 |
| - Preview environments are published to a URL that includes the environment or branch name as a suffix. For example, if the environment or branch is named `dev`, then the environment is available at a location like `<DEFAULT_HOST_NAME>-dev.<LOCATION>.azurestaticapps.net`. |
35 |
| - |
36 |
| -## Configuration |
37 |
| - |
38 |
| -To enable stable URL environments, make the following changes to your [configuration file](configuration.md). |
39 |
| - |
40 |
| -- Set the `production_branch` input on the `static-web-apps-deploy` GitHub action to your production branch name |
41 |
| -- List the branches you want to include in preview environments in the `on > push > branches` array in your site configuration. |
42 |
| - - Set this array to `**` if you want to track all non-production branches. |
43 |
| -- If you want a single target environment, define the `deployment_environment` input on the `static-web-apps-deploy` GitHub action. |
44 |
| - |
45 |
| -## Examples |
46 |
| - |
47 |
| -The following examples demonstrate how to enable stable preview environments. |
48 |
| - |
49 |
| -### Deployment environment |
50 |
| - |
51 |
| -```yml |
52 |
| -name: Azure Static Web Apps CI/CD |
53 |
| - |
54 |
| -on: |
55 |
| - push: |
56 |
| - branches: |
57 |
| - - "**" |
58 |
| - ... |
59 |
| - |
60 |
| -jobs: |
61 |
| - build_and_deploy_job: |
62 |
| - ... |
63 |
| - name: Build and Deploy Job |
64 |
| - steps: |
65 |
| - - uses: actions/checkout@v2 |
66 |
| - with: |
67 |
| - submodules: true |
68 |
| - - name: Build And Deploy |
69 |
| - id: builddeploy |
70 |
| - uses: Azure/static-web-apps-deploy@v1 |
71 |
| - with: |
72 |
| - ... |
73 |
| - deployment_environment: "dev" |
74 |
| -``` |
75 |
| -
|
76 |
| -> [!NOTE] |
77 |
| -> The `...` denotes code skipped for clarity. |
78 |
| - |
79 |
| -In this case, the named environment is labeled as `dev` and tracks all non-production branches. If you wanted to only track changes specific branches, then define them individually in the `branches` array. |
80 |
| - |
81 |
| -Since the `deployment_environment` value is set, then changes to all branches roll up into a single environment. |
82 |
| - |
83 |
| -### Branch deployments |
84 |
| - |
85 |
| -```yml |
86 |
| -name: Azure Static Web Apps CI/CD |
87 |
| -
|
88 |
| -on: |
89 |
| - push: |
90 |
| - branches: |
91 |
| - - main |
92 |
| - - dev |
93 |
| - - feature1 |
94 |
| - - feature2 |
95 |
| - pull_request: |
96 |
| - types: [opened, synchronize, reopened, closed] |
97 |
| - branches: |
98 |
| - - main |
99 |
| -
|
100 |
| -jobs: |
101 |
| - build_and_deploy_job: |
102 |
| - ... |
103 |
| - name: Build and Deploy Job |
104 |
| - steps: |
105 |
| - - uses: actions/checkout@v2 |
106 |
| - with: |
107 |
| - submodules: true |
108 |
| - - name: Build And Deploy |
109 |
| - id: builddeploy |
110 |
| - uses: Azure/static-web-apps-deploy@v1 |
111 |
| - with: |
112 |
| - ... |
113 |
| - production_branch: "main" |
114 |
| -``` |
115 |
| - |
116 |
| -> [!NOTE] |
117 |
| -> The `...` denotes code skipped for clarity. |
| 28 | +- [**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`. |
118 | 29 |
|
119 |
| -Here, the preview environments are defined for the `dev`, `feature1`, and `feature2` branches. Since the `deployment_environment` value isn't set, then each branch is deployed to its own environment. |
| 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`. |
120 | 31 |
|
121 | 32 | ## Next Steps
|
122 | 33 |
|
|
0 commit comments