Skip to content

wip: setting up Azure deployments #3764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: spectrum-two
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/publish-site-azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish documentation (Azure)
#
# This workflow publishes the documentation to Azure static web apps
#

on:
pull_request:
types: [opened, synchronize, reopened, closed]
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"