This repository was archived by the owner on Jul 4, 2025. It is now read-only.
New Documentation for Cortex #905
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: Cortex Docs | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/docs.yml' | |
| pull_request: | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/docs.yml' | |
| schedule: | |
| - cron: "0 22 * * 1,2,3,4,5,6" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| deployments: write | |
| pull-requests: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| deploy-docusaurus: | |
| name: Deploy Docusaurus to Cloudflare Pages | |
| env: | |
| CLOUDFLARE_PROJECT_NAME: cortex-docs | |
| runs-on: ubuntu-latest | |
| if: false # Disable this job if you've fully migrated to Astro | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Install jq | |
| uses: dcarbone/install-jq-action@v2.0.1 | |
| - name: Fill env vars | |
| working-directory: docs | |
| continue-on-error: true | |
| run: | | |
| env_example_file=".env.example" | |
| touch .env | |
| while IFS= read -r line || [[ -n "$line" ]]; do | |
| if [[ "$line" == *"="* ]]; then | |
| var_name=$(echo $line | cut -d '=' -f 1) | |
| echo $var_name | |
| var_value="$(jq -r --arg key "$var_name" '.[$key]' <<< "$SECRETS")" | |
| echo "$var_name=$var_value" >> .env | |
| fi | |
| done < "$env_example_file" | |
| env: | |
| SECRETS: "${{ toJson(secrets) }}" | |
| - name: Install dependencies | |
| working-directory: docs | |
| run: yarn install | |
| - name: Build website | |
| working-directory: docs | |
| run: export NODE_ENV=production && yarn build | |
| - name: Copy redirect file | |
| working-directory: docs | |
| continue-on-error: true | |
| run: cp _redirects build/_redirects | |
| - name: Publish to Cloudflare Pages PR Preview and Staging | |
| if: github.event_name == 'pull_request' | |
| uses: cloudflare/pages-action@v1 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }} | |
| directory: ./docs/build | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| id: deployCloudflarePages | |
| - uses: mshick/add-pr-comment@v2 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| message: | | |
| Docusaurus Preview URL: ${{ steps.deployCloudflarePages.outputs.url }} | |
| - name: Publish to Cloudflare Pages Production | |
| if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/dev' && github.event.pull_request.head.repo.full_name != github.repository | |
| uses: cloudflare/pages-action@v1 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }} | |
| directory: ./docs/build | |
| branch: main | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| build-astro: | |
| name: Build Astro Site | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install, build, and upload Astro site | |
| uses: withastro/action@v3 | |
| with: | |
| path: ./docs | |
| # If you're using Bun, specify it | |
| package-manager: bun@latest | |
| deploy-astro: | |
| name: Deploy Astro to GitHub Pages | |
| needs: build-astro | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| deploy-astro-pr-preview: | |
| name: Deploy PR Preview | |
| needs: build-astro | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| preview: true | |
| - name: Add PR comment with preview URL | |
| uses: mshick/add-pr-comment@v2 | |
| with: | |
| message: | | |
| 📝 Documentation Preview: ${{ steps.deployment.outputs.page_url }} |