Skip to content
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
- features/*
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- features/*
jobs:
build_and_run_tests_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Run Tests
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Run Tests
run: |
dotnet test ./test/ProtoBufJsonConverterTests/ProtoBufJsonConverterTests.csproj -c Release
dotnet test ./test/MetadataReferenceServiceTests/MetadataReferenceServiceTests.csproj -c Release
build_and_deploy_job:
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
lfs: false
- name: Build Blazor WASM App
run: dotnet publish ./examples/Blazor/Client8/Client8.csproj -c Release -o ../../app
- name: Build API
run: dotnet publish ./examples/Blazor/Api/Api.csproj -c Release -o ../../api
- name: Install SWA CLI
run: npm install -g @azure/static-web-apps-cli
- name: Deploy to Azure Static Web Apps
env:
SWA_CLI_DEPLOYMENT_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_DESERT_029B2F003 }}
run: swa deploy
close_pull_request_job:
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: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ZEALOUS_DESERT_029B2F003 }}
action: "close"
build_and_deploy_job_wasm:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job WASM
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy WASM
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_BEACH_0D16CEE03 }}
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 your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/examples/ProtoBufJsonConverter.Blazor" # App source code path
api_location: "" # Api source code path - optional
output_location: "wwwroot" # Built app content directory - optional
###### End of Repository/Build Configurations ######
close_pull_request_job_wasm:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job WASM
steps:
- name: Close Pull Request WASM
id: closepullrequest_wasm
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_BEACH_0D16CEE03 }}
action: "close"