Create azure-staticwebapp.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build and push a web application to an Azure Static Web App when you change your code. | |
# - name: Upload a Build Artifact | |
uses: actions/[email protected] | |
with: | |
# Artifact name | |
name: # optional, default is artifact | |
# A file, directory or wildcard pattern that describes what to upload | |
path: | |
# The desired behavior if no files are found using the provided path. | |
Available Options: | |
warn: Output a warning but do not fail the action | |
error: Fail the action with an error message | |
ignore: Do not output any warnings or errors, the action does not fail | |
if-no-files-found: # optional, default is warn | |
# Duration after which artifact will expire in days. 0 means using default retention. | |
Minimum 1 day. Maximum 90 days unless changed from the repository settings page. | |
retention-days: # optional | |
# The level of compression for Zlib to be applied to the artifact archive. The value can range from 0 to 9: - 0: No compression - 1: Best speed - 6: Default compression (same as GNU Gzip) - 9: Best compression Higher levels will result in better compression, but will take longer to complete. For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads. | |
compression-level: # optional, default is 6 | |
# If true, an artifact with a matching name will be deleted before a new one is uploaded. If false, the action will fail if an artifact for the given name already exists. Does not fail if the artifact does not exist. | |
overwrite: # optional, default is false | |
# This workflow assumes you have already created the target Azure Static Web App. | |
# For instructions see https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript | |
# | |
# To configure this workflow: | |
# | |
# 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. | |
# For instructions on obtaining the deployment token see: https://docs.microsoft.com/azure/static-web-apps/deployment-token-management | |
# | |
# 3. Change the values for the APP_LOCATION, API_LOCATION and APP_ARTIFACT_LOCATION, AZURE_STATIC_WEB_APPS_API_TOKEN environment variables (below). | |
# For instructions on setting up the appropriate configuration values go to https://docs.microsoft.com/azure/static-web-apps/front-end-frameworks | |
name: Deploy web app to Azure Static Web Apps | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
branches: [ "master" ] | |
# Environment variables available to all jobs and steps in this workflow | |
env: | |
APP_LOCATION: "/" # location of your client code | |
API_LOCATION: "api" # location of your api source code - optional | |
APP_ARTIFACT_LOCATION: "build" # location of client code build output | |
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing deployment token for your static web app | |
permissions: | |
contents: read | |
jobs: | |
build_and_deploy_job: | |
permissions: | |
contents: read # for actions/checkout to fetch code | |
pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs | |
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | |
runs-on: ubuntu-latest | |
name: Build and Deploy Job | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Build And Deploy | |
id: builddeploy | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app | |
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) | |
action: "upload" | |
###### Repository/Build Configurations - These values can be configured to match you app requirements. ###### | |
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig | |
app_location: ${{ env.APP_LOCATION }} | |
api_location: ${{ env.API_LOCATION }} | |
app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }} | |
###### End of Repository/Build Configurations ###### | |
close_pull_request_job: | |
permissions: | |
contents: none | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
name: Close Pull Request Job | |
steps: | |
- name: Close Pull Request | |
id: closepullrequest | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }} # secret containing api token for app | |
action: "close" |