name: Build Hash Router on: push: branches: [main] pull_request: branches: - main - docusaurus-v** paths: - packages/** - .github/workflows/build-hash-router.yml - .github/actions/** concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true permissions: contents: read # ⚠️ No GitHub Actions cache on purpose, enforced by GitHub for every step # This workflow can write to the repository (GitHub Pages deployment) # See https://docs.github.com/actions/reference/workflows-and-actions/workflow-syntax#cache-mode cache-mode: none jobs: build: name: Build Hash Router timeout-minutes: 30 runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Set up pnpm, Node.js and dependencies uses: $/.github/actions/setup with: # Security: prevents cache poisoning, as this workflow can write to the repository (GitHub Pages deployment) cache: false - name: Build Hash Router run: pnpm build:website:fast env: DOCUSAURUS_PERF_LOGGER: 'true' DOCUSAURUS_ROUTER: 'hash' # Note: hash router + baseUrl do not play well together # This would host at https://meta.github.io/docusaurus/#/docusaurus/ # BASE_URL: '/docusaurus/' # hash router + - name: Upload Website artifact uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: website-hash-router-archive path: website/build #- name: Upload Website Pages artifact # uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 # with: # path: website/build # Separate job: npm dependencies never run with the write token deploy: name: Deploy Hash Router if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }} needs: build timeout-minutes: 10 runs-on: ubuntu-latest permissions: contents: write # for peaceiris/actions-gh-pages to push to the gh-pages branch steps: - name: Download Website artifact uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: website-hash-router-archive path: website/build # Deploy to https://meta.github.io/docusaurus/ - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: website/build ## TODO we should be able to use this new deploy-pages action ## However this requires a Meta admin to configure it here ## https://github.com/meta/docusaurus/settings/pages ## So for now we keep using the former method ## See https://docusaurus.io/docs/deployment#triggering-deployment-with-github-actions #deploy: # name: Deploy to GitHub Pages # if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }} # needs: build # permissions: # pages: write # id-token: write # environment: # name: github-pages # url: ${{ steps.deployment.outputs.page_url }} # runs-on: ubuntu-latest # steps: # - name: Deploy to GitHub Pages # id: deployment # uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5