Skip to content

Update "Setup your docs environment" instructions to match current Hugo Modules layout #6708

Update "Setup your docs environment" instructions to match current Hugo Modules layout

Update "Setup your docs environment" instructions to match current Hugo Modules layout #6708

Workflow file for this run

# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
---
name: Radius Website
on:
workflow_dispatch:
push:
branches:
- edge
- v*.*
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- edge
- v*.*
permissions: {}
concurrency:
group: docs-swa-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
TARGET_OWNER: azure-octo
TARGET_REPO: radius-publisher
TARGET_WORKFLOW_FILE: swa.yml
MAX_WAIT_SECONDS: "600"
POLL_INTERVAL_SECONDS: "15"
PREVIEW_COMMENT_HEADER: swa-preview
BUILD_ARTIFACT_NAME: hugo_build
jobs:
build:
name: Build Hugo Website
if: github.event.action != 'closed'
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read # Required for actions/checkout
environment:
# If a PR into edge, use 'edge'. If a PR into anywhere else, use 'latest'. If a push, use the branch name.
name: ${{ github.event_name == 'pull_request' && (github.base_ref == 'edge' && 'edge' || 'latest') || github.ref_name }}
env:
HUGO_ENV: production
steps:
- name: Checkout docs repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0 # Required for enableGitInfo
persist-credentials: false
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_docs_version.py
- name: Checkout radius repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
repository: radius-project/radius
ref: ${{ env.RELEASE_BRANCH }}
path: ./radius
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: docs/go.mod
cache: false
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
- name: Install Node.js dependencies
working-directory: docs
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || npm install"
- name: Verify installations
working-directory: docs
run: |
echo "Go: $(go version)"
echo "Node.js: $(node --version)"
npm run hugo:version
- name: Generate Swagger docs
run: |
mkdir -p ./docs/static/swagger
cp -r ./radius/swagger ./docs/static/
- name: Override git_branch for PR
if: github.event_name == 'pull_request'
run: |
# Within docs/config.toml, replace the line that starts with "github_branch" with "github_branch: $GITHUB_HEAD_REF"
sed -i "s|github_branch = .*|github_branch = \"$GITHUB_HEAD_REF\"|" docs/config.toml
- name: Restore Hugo cache
id: cache-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ runner.temp }}/hugo_cache
key: hugo-${{ github.run_id }}
restore-keys: hugo-
- name: Build Hugo Site
working-directory: docs
run: |
if [ "${GITHUB_EVENT_NAME}" == 'pull_request' ]; then
STAGING_URL="https://${ENV_STATICWEBAPP_BASE}-${GITHUB_EVENT_NUMBER}.westus2.3.azurestaticapps.net/"
fi
npm run build -- ${STAGING_URL+-b "$STAGING_URL"} --cacheDir "${RUNNER_TEMP}/hugo_cache"
env:
ENV_STATICWEBAPP_BASE: ${{ vars.ENV_STATICWEBAPP_BASE }}
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
RUNNER_TEMP: ${{ runner.temp }}
- name: Save Hugo cache
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ runner.temp }}/hugo_cache
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Upload Hugo artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.BUILD_ARTIFACT_NAME }}
path: ./docs/public/
if-no-files-found: error
retention-days: 1
# deploy:
# name: Deploy Hugo Website to App Service
# if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
# needs: [build]
# runs-on: ubuntu-24.04
# timeout-minutes: 5
# permissions:
# id-token: write # Required for requesting the JWT
# contents: read # Required for actions/checkout
# environment:
# # If push to edge, use 'edge'. If push to anywhere else, use 'latest'.
# name: ${{ github.ref_name == 'edge' && 'edge' || 'latest' }}
# url: ${{ github.ref_name == 'edge' && 'https://edge.docs.radapp.io' || 'https://docs.radapp.io' }}
# steps:
# - name: Checkout docs repo
# uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
# with:
# submodules: false
# persist-credentials: false
# - name: Download Hugo artifacts
# uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
# with:
# name: ${{ env.BUILD_ARTIFACT_NAME }}
# path: site/
# - name: Login to Azure
# uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
# with:
# client-id: ${{ secrets.AZURE_SP_TESTS_APPID }}
# tenant-id: ${{ secrets.AZURE_SP_TESTS_TENANTID }}
# subscription-id: ${{ vars.ENV_APPSERVICE_SUBSCRIPTIONID }}
# - name: Deploy to WebApp
# uses: Azure/webapps-deploy@84a80cfe7e9889f35148ed88c307e6e93bf02578 # v3.0.7
# with:
# app-name: ${{ vars.ENV_APPSERVICE_NAME }}
# resource-group-name: ${{ vars.ENV_APPSERVICE_RESOURCEGROUP }}
# package: site/
dispatch-production:
name: Dispatch Static Web App Deploy
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: [build]
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
environment:
name: ${{ github.ref_name == 'edge' && 'edge' || 'latest' }}
url: ${{ github.ref_name == 'edge' && 'https://edge.docs.radapp.io' || 'https://docs.radapp.io' }}
steps:
- name: Checkout docs repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
sparse-checkout: |
.github/scripts/monitor-remote-workflow.mjs
- name: Get App Token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: github-app-token
with:
app-id: ${{ secrets.RADIUS_PUBLISHER_BOT_APP_ID }}
private-key: ${{ secrets.RADIUS_PUBLISHER_BOT_PRIVATE_KEY }}
permission-metadata: read
permission-actions: read
permission-contents: write
owner: ${{ env.TARGET_OWNER }}
repositories: |
${{ env.TARGET_REPO }}
- name: Capture dispatch start time
id: dispatch-start
run: |
echo "started_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${GITHUB_OUTPUT}"
- name: Dispatch static web app deploy
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ steps.github-app-token.outputs.token }}
repository: ${{ env.TARGET_OWNER }}/${{ env.TARGET_REPO }}
event-type: swa
client-payload: |-
{
"action": "deploy",
"environment": "production",
"source_repository": "${{ github.repository }}",
"source_run_id": "${{ github.run_id }}",
"artifact_name": "${{ env.BUILD_ARTIFACT_NAME }}",
"swa_cli_app_name": "${{ vars.ENV_STATICWEBAPP_NAME }}"
}
- name: Monitor remote workflow
id: monitor
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ steps.github-app-token.outputs.token }}
script: |
const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/monitor-remote-workflow.mjs`)
await script({github, core})
env:
INPUT_OWNER: ${{ env.TARGET_OWNER }}
INPUT_REPO: ${{ env.TARGET_REPO }}
INPUT_WORKFLOW_FILE: ${{ env.TARGET_WORKFLOW_FILE }}
INPUT_DISPATCH_STARTED_AT: ${{ steps.dispatch-start.outputs.started_at }}
INPUT_MAX_WAIT_SECONDS: ${{ env.MAX_WAIT_SECONDS }}
INPUT_POLL_INTERVAL_SECONDS: ${{ env.POLL_INTERVAL_SECONDS }}
- name: Show failed logs
if: failure()
run: |
gh run view "${RUN_ID}" --repo "${TARGET_OWNER}/${TARGET_REPO}" --log-failed || true
env:
GH_TOKEN: ${{ steps.github-app-token.outputs.token }}
RUN_ID: ${{ steps.monitor.outputs.run_id }}
dispatch-preview:
name: Dispatch Static Web App Preview
if: >-
github.event_name == 'pull_request'
&& github.event.action != 'closed'
&& github.event.pull_request.head.repo.full_name == github.repository
needs: [build]
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
environment:
name: ${{ github.base_ref == 'edge' && 'edge' || 'latest' }}
steps:
- name: Checkout docs repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
sparse-checkout: |
.github/scripts/monitor-remote-workflow.mjs
- name: Get App Token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: github-app-token
with:
app-id: ${{ secrets.RADIUS_PUBLISHER_BOT_APP_ID }}
private-key: ${{ secrets.RADIUS_PUBLISHER_BOT_PRIVATE_KEY }}
permission-metadata: read
permission-actions: read
permission-contents: write
owner: ${{ env.TARGET_OWNER }}
repositories: |
${{ env.TARGET_REPO }}
- name: Capture dispatch start time
id: dispatch-start
run: |
echo "started_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${GITHUB_OUTPUT}"
- name: Dispatch static web app preview
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ steps.github-app-token.outputs.token }}
repository: ${{ env.TARGET_OWNER }}/${{ env.TARGET_REPO }}
event-type: swa
client-payload: |-
{
"action": "deploy",
"environment": "preview",
"pr_number": ${{ github.event.pull_request.number }},
"source_repository": "${{ github.repository }}",
"source_run_id": "${{ github.run_id }}",
"artifact_name": "${{ env.BUILD_ARTIFACT_NAME }}",
"swa_cli_app_name": "${{ vars.ENV_STATICWEBAPP_NAME }}"
}
- name: Monitor remote workflow
id: monitor
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ steps.github-app-token.outputs.token }}
script: |
const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/monitor-remote-workflow.mjs`)
await script({github, core})
env:
INPUT_OWNER: ${{ env.TARGET_OWNER }}
INPUT_REPO: ${{ env.TARGET_REPO }}
INPUT_WORKFLOW_FILE: ${{ env.TARGET_WORKFLOW_FILE }}
INPUT_DISPATCH_STARTED_AT: ${{ steps.dispatch-start.outputs.started_at }}
INPUT_MAX_WAIT_SECONDS: ${{ env.MAX_WAIT_SECONDS }}
INPUT_POLL_INTERVAL_SECONDS: ${{ env.POLL_INTERVAL_SECONDS }}
- name: Upsert preview PR comment
if: success()
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
with:
header: ${{ env.PREVIEW_COMMENT_HEADER }}
skip_unchanged: true
message: |
### Static Web App Preview
| Environment | Deployment |
|---|---|
| pr${{ github.event.pull_request.number }} | [View workflow run](${{ steps.monitor.outputs.run_url }}) |
_Deployed from commit `${{ github.event.pull_request.head.sha }}` via the publisher workflow._
- name: Show failed logs
if: failure()
run: |
gh run view "${RUN_ID}" --repo "${TARGET_OWNER}/${TARGET_REPO}" --log-failed || true
env:
GH_TOKEN: ${{ steps.github-app-token.outputs.token }}
RUN_ID: ${{ steps.monitor.outputs.run_id }}
dispatch-cleanup:
name: Dispatch Static Web App Preview Cleanup
if: >-
github.event_name == 'pull_request'
&& github.event.action == 'closed'
&& github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
environment:
name: ${{ github.base_ref == 'edge' && 'edge' || 'latest' }}
url: ${{ github.base_ref == 'edge' && 'https://edge.docs.radapp.io' || 'https://docs.radapp.io' }}
steps:
- name: Checkout docs repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
sparse-checkout: |
.github/scripts/monitor-remote-workflow.mjs
- name: Get App Token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: github-app-token
with:
app-id: ${{ secrets.RADIUS_PUBLISHER_BOT_APP_ID }}
private-key: ${{ secrets.RADIUS_PUBLISHER_BOT_PRIVATE_KEY }}
permission-metadata: read
permission-actions: read
permission-contents: write
owner: ${{ env.TARGET_OWNER }}
repositories: |
${{ env.TARGET_REPO }}
- name: Delete preview PR comment
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
with:
header: ${{ env.PREVIEW_COMMENT_HEADER }}
delete: true
- name: Capture dispatch start time
id: dispatch-start
run: |
echo "started_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "${GITHUB_OUTPUT}"
- name: Dispatch static web app preview cleanup
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ steps.github-app-token.outputs.token }}
repository: ${{ env.TARGET_OWNER }}/${{ env.TARGET_REPO }}
event-type: swa
client-payload: |-
{
"action": "close",
"source_repository": "${{ github.repository }}",
"pr_number": ${{ github.event.pull_request.number }},
"swa_cli_app_name": "${{ vars.ENV_STATICWEBAPP_NAME }}"
}
- name: Monitor remote workflow
id: monitor
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ steps.github-app-token.outputs.token }}
script: |
const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/monitor-remote-workflow.mjs`)
await script({github, core})
env:
INPUT_OWNER: ${{ env.TARGET_OWNER }}
INPUT_REPO: ${{ env.TARGET_REPO }}
INPUT_WORKFLOW_FILE: ${{ env.TARGET_WORKFLOW_FILE }}
INPUT_DISPATCH_STARTED_AT: ${{ steps.dispatch-start.outputs.started_at }}
INPUT_MAX_WAIT_SECONDS: ${{ env.MAX_WAIT_SECONDS }}
INPUT_POLL_INTERVAL_SECONDS: ${{ env.POLL_INTERVAL_SECONDS }}
- name: Show failed logs
if: failure()
run: |
gh run view "${RUN_ID}" --repo "${TARGET_OWNER}/${TARGET_REPO}" --log-failed || true
env:
GH_TOKEN: ${{ steps.github-app-token.outputs.token }}
RUN_ID: ${{ steps.monitor.outputs.run_id }}
algolia_index:
name: Index site for Algolia
if: github.event_name == 'push'
needs: [build, dispatch-production]
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read # Required for actions/checkout
environment:
# If push to edge, use 'edge'. If push to anywhere else, use 'latest'.
name: ${{ github.ref_name == 'edge' && 'edge' || 'latest' }}
steps:
- name: Checkout docs repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
submodules: false
persist-credentials: false
- name: Download Hugo artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.BUILD_ARTIFACT_NAME }}
path: site/
- name: Install Python packages
run: |
pip install --upgrade bs4
pip install --upgrade 'algoliasearch>=2.0,<3.0'
- name: Index site
run: python ./.github/scripts/algolia.py ./site
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_API_APPID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ENV_ALGOLIA_INDEXNAME }}