ci: adopt shared reusable release workflows + pin-at-release OCI publishing #47
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: ['docs/**', 'scripts/check-links.sh', '.github/workflows/docs.yml'] | |
| pull_request: | |
| paths: ['docs/**', 'scripts/check-links.sh', '.github/workflows/docs.yml'] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: docs-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| PACK_SLUG: llm-serving-pack | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: { fetch-depth: 0 } | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: docs/package-lock.json | |
| - name: Install deps | |
| working-directory: docs | |
| run: npm ci | |
| - name: Install Playwright (mermaid rendering) | |
| working-directory: docs | |
| run: npx playwright install --with-deps chromium | |
| - name: Unit tests | |
| working-directory: docs | |
| run: npm test | |
| - name: Compute site, base, and deploy branch | |
| id: base | |
| env: | |
| HEAD_REF: ${{ github.head_ref || github.ref_name }} | |
| run: | | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| echo "site=https://packs.nebari.dev" >> "$GITHUB_OUTPUT" | |
| echo "base=/${PACK_SLUG}/" >> "$GITHUB_OUTPUT" | |
| echo "branch=main" >> "$GITHUB_OUTPUT" | |
| else | |
| ALIAS=$(printf '%s' "$HEAD_REF" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g') | |
| echo "site=https://${ALIAS}.${PACK_SLUG}.pages.dev" >> "$GITHUB_OUTPUT" | |
| echo "base=/" >> "$GITHUB_OUTPUT" | |
| echo "branch=${HEAD_REF}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build | |
| working-directory: docs | |
| env: | |
| SITE: ${{ steps.base.outputs.site }} | |
| BASE: ${{ steps.base.outputs.base }} | |
| run: npm run build | |
| - name: Check internal links | |
| env: | |
| BASE: ${{ steps.base.outputs.base }} | |
| run: SKIP_BUILD=1 bash scripts/check-links.sh | |
| # Fork PRs cannot read secrets; skip deploy there (build + link-check still gate). | |
| - name: Deploy to Cloudflare Pages | |
| id: deploy | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} | |
| uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: pages deploy docs/dist --project-name=${{ env.PACK_SLUG }} --branch=${{ steps.base.outputs.branch }} | |
| - name: Comment preview URL | |
| if: ${{ github.event_name == 'pull_request' && steps.deploy.outcome == 'success' }} | |
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | |
| with: | |
| header: docs-preview | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| message: | | |
| 📄 **Docs preview** for `${{ github.event.pull_request.head.ref }}`: | |
| ${{ steps.deploy.outputs.pages-deployment-alias-url }} |