Skip to content

test-deployed

test-deployed #289

Workflow file for this run

name: Deploy
# main is the test channel and release the prod channel. A push builds the branch it lands on, and
# the deployment side rebuilds a channel when its environment changes, through a repository_dispatch:
# `test-deployed` for test, `prod-promoted` for prod. A build reads the channel's OpenAPI document
# from its API, so the reference is always what that environment serves.
#
# Each channel is a GitHub environment of the same name holding DOCS_API_URL and DOCS_CONSOLE_URL,
# as variables where the origins are public and as secrets where they are not.
on:
push:
branches: [main, release]
repository_dispatch:
types: [test-deployed, prod-promoted]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: deploy-${{ (github.ref_name == 'release' || github.event.action == 'prod-promoted') && 'prod' || 'test' }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
environment: ${{ (github.ref_name == 'release' || github.event.action == 'prod-promoted') && 'prod' || 'test' }}
env:
DOCS_CHANNEL: ${{ (github.ref_name == 'release' || github.event.action == 'prod-promoted') && 'prod' || 'test' }}
DOCS_API_URL: ${{ secrets.DOCS_API_URL || vars.DOCS_API_URL }}
DOCS_CONSOLE_URL: ${{ secrets.DOCS_CONSOLE_URL || vars.DOCS_CONSOLE_URL }}
steps:
- uses: actions/checkout@v7
with:
# A dispatch runs on the default branch; prod's content is the release branch.
ref: ${{ env.DOCS_CHANNEL == 'prod' && 'release' || github.ref }}
# An origin held as a secret is masked as a whole; its host is masked here too, so an error
# naming only the host stays out of this public log.
- name: Mask the channel's hosts
run: |
for url in "$DOCS_API_URL" "$DOCS_CONSOLE_URL"; do
host="${url#*://}"
host="${host%%/*}"
[ -n "$host" ] && echo "::add-mask::$host"
done
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: |
if [ "$DOCS_CHANNEL" = test ]; then set -- --env test; fi
pnpm run deploy -- "$@"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}