Skip to content

Commit cd99b74

Browse files
authored
Create azure-staticwebapp.yml
1 parent 467eaa1 commit cd99b74

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This workflow will build and push a web application to an Azure Static Web App when you change your code.
2+
#
3+
# This workflow assumes you have already created the target Azure Static Web App.
4+
# For instructions see https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript
5+
#
6+
# To configure this workflow:
7+
#
8+
# 1. Set up a secret in your repository named AZURE_STATIC_WEB_APPS_API_TOKEN with the value of your Static Web Apps deployment token.
9+
# For instructions on obtaining the deployment token see: https://docs.microsoft.com/azure/static-web-apps/deployment-token-management
10+
#
11+
# 3. Change the values for the APP_LOCATION, API_LOCATION and APP_ARTIFACT_LOCATION, AZURE_STATIC_WEB_APPS_API_TOKEN environment variables (below).
12+
# For instructions on setting up the appropriate configuration values go to https://docs.microsoft.com/azure/static-web-apps/front-end-frameworks
13+
name: Deploy web app to Azure Static Web Apps
14+
15+
on:
16+
push:
17+
branches: [ "master" ]
18+
pull_request:
19+
types: [opened, synchronize, reopened, closed]
20+
branches: [ "master" ]
21+
22+
# Environment variables available to all jobs and steps in this workflow
23+
env:
24+
APP_LOCATION: "/" # location of your client code
25+
API_LOCATION: "api" # location of your api source code - optional
26+
APP_ARTIFACT_LOCATION: "build" # location of client code build output
27+
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing deployment token for your static web app
28+
29+
permissions:
30+
contents: read
31+
32+
jobs:
33+
build_and_deploy_job:
34+
permissions:
35+
contents: read # for actions/checkout to fetch code
36+
pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs
37+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
38+
runs-on: ubuntu-latest
39+
name: Build and Deploy Job
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
submodules: true
44+
- name: Build And Deploy
45+
id: builddeploy
46+
uses: Azure/static-web-apps-deploy@v1
47+
with:
48+
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app
49+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
50+
action: "upload"
51+
###### Repository/Build Configurations - These values can be configured to match you app requirements. ######
52+
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
53+
app_location: ${{ env.APP_LOCATION }}
54+
api_location: ${{ env.API_LOCATION }}
55+
app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }}
56+
###### End of Repository/Build Configurations ######
57+
58+
close_pull_request_job:
59+
permissions:
60+
contents: none
61+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
62+
runs-on: ubuntu-latest
63+
name: Close Pull Request Job
64+
steps:
65+
- name: Close Pull Request
66+
id: closepullrequest
67+
uses: Azure/static-web-apps-deploy@v1
68+
with:
69+
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app
70+
action: "close"

0 commit comments

Comments
 (0)