Skip to content

chore: achieve hero panel refinement mission #3

chore: achieve hero panel refinement mission

chore: achieve hero panel refinement mission #3

Workflow file for this run

name: Docs
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
inputs:
deploy:
description: "Deploy after the docs build completes"
required: true
default: false
type: boolean
concurrency:
group: docs-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
name: Build Docs
runs-on: ubuntu-latest
permissions:
contents: read
env:
DOCS_SITE_URL: ${{ vars.TRANSIT_DOCS_SITE_URL }}
DOCS_BASE_URL: ${{ vars.TRANSIT_DOCS_BASE_URL }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: website/package-lock.json
- name: Install website dependencies
run: npm --prefix website ci
- name: Build docs site
run: npm --prefix website run build
- name: Upload static site artifact
uses: actions/upload-artifact@v4
with:
name: transit-docs-site
path: website/build
if-no-files-found: error
deploy:
name: Deploy Docs
needs: build
runs-on: ubuntu-latest
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main' && vars.TRANSIT_DOCS_DEPLOY_ENABLED == 'true') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy)
permissions:
contents: read
id-token: write
env:
TRANSIT_DOCS_BUCKET: ${{ vars.TRANSIT_DOCS_BUCKET }}
TRANSIT_DOCS_DISTRIBUTION_ID: ${{ vars.TRANSIT_DOCS_DISTRIBUTION_ID }}
TRANSIT_DOCS_AWS_ROLE_ARN: ${{ vars.TRANSIT_DOCS_AWS_ROLE_ARN }}
AWS_REGION: ${{ vars.TRANSIT_DOCS_AWS_REGION != '' && vars.TRANSIT_DOCS_AWS_REGION || 'us-east-1' }}
steps:
- name: Validate deploy configuration
shell: bash
run: |
set -euo pipefail
missing=0
for name in TRANSIT_DOCS_BUCKET TRANSIT_DOCS_DISTRIBUTION_ID TRANSIT_DOCS_AWS_ROLE_ARN; do
if [[ -z "${!name:-}" ]]; then
echo "Missing required repository variable: $name" >&2
missing=1
fi
done
if [[ "${missing}" -ne 0 ]]; then
exit 1
fi
- uses: actions/download-artifact@v4
with:
name: transit-docs-site
path: website-build
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ env.TRANSIT_DOCS_AWS_ROLE_ARN }}
- name: Sync docs to S3
run: aws s3 sync website-build/ "s3://${TRANSIT_DOCS_BUCKET}/" --delete
- name: Invalidate CloudFront
run: aws cloudfront create-invalidation --distribution-id "${TRANSIT_DOCS_DISTRIBUTION_ID}" --paths '/*'