Skip to content

wip: setting up Azure deployments #26

wip: setting up Azure deployments

wip: setting up Azure deployments #26

name: Publish documentation (Azure)
#
# This workflow publishes the documentation to Azure static web apps
#
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- "**"
permissions:
contents: read
pull-requests: write
jobs:
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:
## --- SETUP --- ##
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node LTS version
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Enable Corepack
run: corepack enable
- name: Clean up comments from previous Azure deploys
if: github.event_name == 'pull_request'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr=${{ github.event.pull_request.number }}
comments=$(gh api repos/${{ github.repository }}/issues/$pr/comments)
echo "$comments" | jq -c '.[]' | while read -r comment; do
body=$(echo "$comment" | jq -r '.body')
id=$(echo "$comment" | jq -r '.id')
if [[ "$body" == Azure\ Static\ Web\ Apps:* ]]; then
echo "Deleting comment $id"
gh api repos/${{ github.repository }}/issues/comments/$id -X DELETE
fi
done
## --- YARN CACHE --- ##
- name: Check for cached dependencies
continue-on-error: true
id: cache-dependencies
uses: actions/cache@v4
with:
path: |
.cache/yarn
node_modules
key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }}
## --- INSTALL --- ##
# note: if cache-hit isn't needed b/c yarn will leverage the cache if it exists
- name: Install dependencies
shell: bash
run: yarn install --immutable
- 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_POLITE_CLIFF_0173AA90F }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/"
api_location: ""
output_location: "dist"
app_build_command: "yarn build:docs"
timeout-minutes: 10
close_pull_request_job:
if: github.event.action == 'closed'
runs-on: ubuntu-latest
name: Clean up PR environment
steps:
- name: Remove PR environment
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_CLIFF_0173AA90F }}
action: "close"