In this article, you will learn how to deploy and create a continuous integration in GitHub using GitHub actions and Azure static web apps.
First, we need a lading page or static site that only uses html, css and JS.
In this workflow, we detect changes over the main branch and pull requests against this branch. In the property "app_location" you need to set the folder where your app is located or just use "/" if it is located in the base path.
name:Azure Static Web Apps for Static Siteson:push:branches:-mainpull_request:types:[opened,synchronize,reopened,closed]branches:-mainjobs:build_and_deploy_job:if:github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')runs-on:ubuntu-latestname:Build and Deploy Jobsteps:-uses:actions/checkout@v2with:submodules:true-name:Build And Deployid:builddeployuses:Azure/static-web-apps-deploy@v1with: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"app_location:"/union"# App source code pathskip_app_build:trueclose_pull_request_job:if:github.event_name == 'pull_request' && github.event.action == 'closed'runs-on:ubuntu-latestname:Close Pull Request Jobsteps:-name:Close Pull Requestid:closepullrequestuses:Azure/static-web-apps-deploy@v1with:azure_static_web_apps_api_token:${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}action:"close"
We are using the secret AZURE_STATIC_WEB_APPS_API_TOKEN to deploy azure static web apps. After creating a new Azure static site, you just need to get the token to deploy the site.
In the settings of the project, you need to create this key, copying the value from Azure static web apps.