Skip to content

Instantly share code, notes, and snippets.

@rdvm
Created October 17, 2023 17:46
Show Gist options
  • Save rdvm/404af6d05152ae04a4d6b07bfd4e0ed1 to your computer and use it in GitHub Desktop.
Save rdvm/404af6d05152ae04a4d6b07bfd4e0ed1 to your computer and use it in GitHub Desktop.
MkDocs >> Azure Static Web App GitHub Actions Workflow
name: Azure Static Web Apps CI/CD
env:
DEPLOYMENT_PROVIDER: "Custom"
REPOSITORY_URL: ${{github.event.repository.html_url}}
BRANCH: ${{github.event.pull_request.head.ref}}
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
permissions:
contents: read
pull-requests: write
jobs:
build_and_deploy_job:
if: 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: Docker Compose Build
run: docker compose -f docker-compose-build.yml up
- name: Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_<SWAName> }}
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: "site/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
skip_app_build: true
skip_api_build: true
deployment_environment: "staging"
###### End of Repository/Build Configurations ######
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Azure Static Web Apps: Your stage site is ready! Visit it here: <https://<SWAName>-staging.centralus.3.azurestaticapps.net
close_pull_request_job:
if: github.event_name == 'push'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Docker Compose Build
run: docker compose -f docker-compose-build.yml up
- 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_<SWAName> }}
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: "site/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
skip_app_build: true
skip_api_build: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment