You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -31,15 +32,31 @@ With these settings, you can set up GitHub Actions or [Azure Pipelines](get-star
31
32
32
33
## File name and location
33
34
34
-
# [GitHub Actions](#tab/github-actions)
35
+
<!--
36
+
::: zone pivot="azure-pipelines"
37
+
38
+
39
+
40
+
::: zone-end
41
+
42
+
::: zone pivot="github-actions"
43
+
44
+
45
+
46
+
::: zone-end
47
+
-->
48
+
49
+
::: zone pivot="azure-pipelines"
35
50
36
51
The GitHub action generates the configuration file and is stored in the *.github/workflows* folder, named using the following format: `azure-static-web-apps-<RANDOM_NAME>.yml`.
37
52
38
-
# [Azure Pipelines](#tab/azure-devops)
53
+
::: zone-end
54
+
55
+
::: zone pivot="github-actions"
39
56
40
57
By default, the configuration file is stored at the root of your repository with the name `azure-pipelines.yml`.
41
58
42
-
---
59
+
::: zone-end
43
60
44
61
## Security
45
62
@@ -58,7 +75,44 @@ The following sample configuration monitors the repository for changes. As commi
58
75
> [!NOTE]
59
76
> This example shows a sample configuration that uses an Azure deployment token to secure the build configuration.
60
77
61
-
# [GitHub Actions](#tab/github-actions)
78
+
::: zone pivot="azure-pipelines"
79
+
80
+
```yaml
81
+
trigger:
82
+
- main
83
+
84
+
pool:
85
+
vmImage: ubuntu-latest
86
+
87
+
steps:
88
+
- checkout: self
89
+
submodules: true
90
+
- task: AzureStaticWebApp@0
91
+
inputs:
92
+
app_location: 'src'# App source code path relative to cwd
93
+
api_location: 'api'# Api source code path relative to cwd
94
+
output_location: 'public'# Built app content directory relative to app_location - optional
95
+
cwd: '$(System.DefaultWorkingDirectory)/myapp'# Working directory - optional
- The `app_location` points to the `src` folder that contains the source files for the web app. This value is relative to the working directory (`cwd`). To set it to the working directory, use `/`.
103
+
- The `api_location` points to the `api` folder that contains the Azure Functions application for the site's API endpoints. This value is relative to the working directory (`cwd`). To set it to the working directory, use `/`.
104
+
- The `output_location` points to the `public` folder that contains the final version of the app's source files. This value is relative to `app_location`. For .NET projects, the location is relative to the output folder.
105
+
- The `cwd` is an absolute path pointing to the working directory. It defaults to `$(System.DefaultWorkingDirectory)`.
106
+
- The `$(deployment_token)` variable points to the [generated Azure DevOps deployment token](./deployment-token-management.md).
107
+
108
+
> [!NOTE]
109
+
> `app_location` and `api_location` must be relative to the working directory (`cwd`) and they must be subdirectories under `cwd`.
- A GitHub Actions workflow is [triggered](https://help.github.com/actions/reference/events-that-trigger-workflows) when a pull request on the `main` branch is: opened, synchronized, reopened, or closed.
131
236
- The `build_and_deploy_job` executes when you push commits or open a pull request against the branch listed in the `on` property.
132
-
- One of the `steps` makes an `idtoken` available to authenticate the build process with Azure services.
133
237
- The `app_location` points to the `src` folder that contains the source files for the web app. To set this value to the repository root, use `/`.
134
238
- The `api_location` points to the `api` folder that contains the Azure Functions application for the site's API endpoints. To set this value to the repository root, use `/`.
135
239
- The `output_location` points to the `public` folder that contains the final version of the app's source files. It's relative to `app_location`. For .NET projects, the location is relative to the publish output folder.
@@ -144,40 +248,7 @@ This job helps keep your pull request workflow organized and prevents stale pull
144
248
145
249
The *Close Pull Request* job is part of the Azure Static Web Apps GitHub Actions workflow, closing the pull request after it's merged. The `Azure/static-web-apps-deploy` action deploys the app to Azure Static Web Apps, requiring the `azure_static_web_apps_api_token` for authentication.
146
250
147
-
# [Azure Pipelines](#tab/azure-devops)
148
-
149
-
```yaml
150
-
trigger:
151
-
- main
152
-
153
-
pool:
154
-
vmImage: ubuntu-latest
155
-
156
-
steps:
157
-
- checkout: self
158
-
submodules: true
159
-
- task: AzureStaticWebApp@0
160
-
inputs:
161
-
app_location: 'src' # App source code path relative to cwd
162
-
api_location: 'api' # Api source code path relative to cwd
163
-
output_location: 'public' # Built app content directory relative to app_location - optional
164
-
cwd: '$(System.DefaultWorkingDirectory)/myapp' # Working directory - optional
- The `app_location` points to the `src` folder that contains the source files for the web app. This value is relative to the working directory (`cwd`). To set it to the working directory, use `/`.
172
-
- The `api_location` points to the `api` folder that contains the Azure Functions application for the site's API endpoints. This value is relative to the working directory (`cwd`). To set it to the working directory, use `/`.
173
-
- The `output_location` points to the `public` folder that contains the final version of the app's source files. This value is relative to `app_location`. For .NET projects, the location is relative to the output folder.
174
-
- The `cwd` is an absolute path pointing to the working directory. It defaults to `$(System.DefaultWorkingDirectory)`.
175
-
- The `$(deployment_token)` variable points to the [generated Azure DevOps deployment token](./deployment-token-management.md).
176
-
177
-
> [!NOTE]
178
-
> `app_location` and `api_location` must be relative to the working directory (`cwd`) and they must be subdirectories under `cwd`.
179
-
180
-
---
251
+
::: zone-end
181
252
182
253
## Custom build commands
183
254
@@ -187,7 +258,7 @@ For Node.js applications, you can take fine-grained control over what commands r
187
258
> Currently, you can only define `app_build_command` and `api_build_command` for Node.js builds.
188
259
> To specify the Node.js version, use the [`engines`](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#engines) field in the `package.json` file.
@@ -281,7 +356,7 @@ Steps to skip building the API:
281
356
- Set `skip_api_build` to `true`.
282
357
- Set `api_location` to the folder containing the built API app to deploy. This path is relative to the repository root in GitHub Actions and `cwd` in Azure Pipelines.
Sometimes you need your workflow to continue to process even when some secrets are missing. To configure your workflow to proceed without defined secrets, set the `SKIP_DEPLOY_ON_MISSING_SECRETS` environment variable to `true`.
351
430
352
431
When enabled, this feature allows the workflow to continue without deploying the site's content.
353
432
354
-
# [GitHub Actions](#tab/github-actions)
433
+
::: zone pivot="github-actions"
355
434
356
435
```yaml
357
436
...
@@ -367,7 +446,9 @@ env:
367
446
SKIP_DEPLOY_ON_MISSING_SECRETS: true
368
447
```
369
448
370
-
# [Azure Pipelines](#tab/azure-devops)
449
+
::: zone-end
450
+
451
+
::: zone pivot="azure-pipelines"
371
452
372
453
```yaml
373
454
...
@@ -381,15 +462,15 @@ env:
381
462
SKIP_DEPLOY_ON_MISSING_SECRETS: true
382
463
```
383
464
384
-
---
465
+
::: zone-end
385
466
386
467
## Environment variables
387
468
388
469
You can set environment variables for your build via the `env` section of a job's configuration.
389
470
390
471
For more information about the environment variables used by Oryx, see [Oryx configuration](https://github.com/microsoft/Oryx/blob/main/doc/configuration.md).
391
472
392
-
# [GitHub Actions](#tab/github-actions)
473
+
::: zone pivot="github-actions"
393
474
394
475
```yaml
395
476
...
@@ -405,7 +486,9 @@ env: # Add environment variables here
405
486
HUGO_VERSION: 0.58.0
406
487
```
407
488
408
-
# [Azure Pipelines](#tab/azure-devops)
489
+
::: zone-end
490
+
491
+
::: zone pivot="azure-pipelines"
409
492
410
493
```yml
411
494
...
@@ -419,15 +502,15 @@ env: # Add environment variables here
419
502
HUGO_VERSION: 0.58.0
420
503
```
421
504
422
-
---
505
+
::: zone-end
423
506
424
507
## Monorepo support
425
508
426
509
A monorepo is a repository that contains code for more than one application. By default, the workflow tracks all files in a repository, but you can adjust the configuration to target a single app.
427
510
428
511
To target a workflow file to a single app, you specify paths in the `push` and `pull_request` sections.
429
512
430
-
# [GitHub Actions](#tab/github-actions)
513
+
::: zone pivot="github-actions"
431
514
432
515
When you set up a monorepo, each static app configuration is scoped to only files for a single app. The different workflow files live side by side in the repository's _.github/workflows_ folder.
433
516
@@ -473,11 +556,13 @@ In this example, only changes made to following files trigger a new build:
473
556
- Any files inside the _api1_ folder
474
557
- Changes to the app's _azure-static-web-apps-purple-pond.yml_ workflow file
475
558
476
-
# [Azure Pipelines](#tab/azure-devops)
559
+
::: zone-end
560
+
561
+
::: zone pivot="azure-pipelines"
477
562
478
563
To support more than one application in a single repository, create a separate workflow file and associate it with different Azure Pipelines.
0 commit comments