Skip to content
name: πŸ‘· πŸš€ Build and Deploy App to Azure Static Web Apps
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
workflow_dispatch:
jobs:
createVersion:
name: πŸ”’ Create Version
outputs:
appVersion: ${{ steps.tag_version.outputs.new_tag }}
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
- name: Bump version and push tag
id: tag_version
uses: laputansoft/github-tag-action@v4.6
with:
release_branches: main
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.package-version.outputs.version }}
build_and_deploy_job:
runs-on: ubuntu-latest
name: πŸ‘· πŸš€ Build and Deploy Job
needs: [createVersion]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Create env file
run: |
touch .env
echo BUILD_VERSION=${{needs.createVersion.outputs.appVersion}} >> .env
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@latest
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
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: '/' # App source code path
api_location: '' # Api source code path - optional
output_location: '' # Built app content directory - optional
###### End of Repository/Build Configurations ######
env: # Add environment variables here
ENABLE_PREVIEW_FEATURES: true
FUNCTION_LANGUAGE: node
FUNCTION_LANGUAGE_VERSION: 16
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_NICE_MUSHROOM_0505A6F03 }}
action: 'close'