microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
.github/workflows/deploy-pages.yml
93lines · modecode
| 1 | # Copyright (c) Microsoft Corporation. |
| 2 | # Licensed under the MIT License. |
| 3 | |
| 4 | name: Build and Deploy Docs |
| 5 | |
| 6 | on: |
| 7 | push: |
| 8 | branches: |
| 9 | - main |
| 10 | |
| 11 | # Only run when docs-related files change |
| 12 | paths: |
| 13 | - 'docs/**' |
| 14 | |
| 15 | # Allow manual deployment from the Actions tab |
| 16 | workflow_dispatch: |
| 17 | |
| 18 | permissions: |
| 19 | contents: read |
| 20 | id-token: write |
| 21 | pages: write |
| 22 | |
| 23 | concurrency: |
| 24 | group: "pages" |
| 25 | cancel-in-progress: false |
| 26 | |
| 27 | jobs: |
| 28 | build-and-deploy: |
| 29 | runs-on: ubuntu-latest |
| 30 | defaults: |
| 31 | run: |
| 32 | working-directory: docs |
| 33 | |
| 34 | permissions: |
| 35 | contents: read |
| 36 | id-token: write |
| 37 | pages: write |
| 38 | |
| 39 | environment: |
| 40 | name: github-pages |
| 41 | url: ${{ steps.deployment.outputs.page_url }} |
| 42 | |
| 43 | steps: |
| 44 | - name: Checkout Repository 🛎️ |
| 45 | uses: actions/checkout@v4 |
| 46 | |
| 47 | - name: Setup Node.js ⚙️ |
| 48 | uses: actions/setup-node@v4 |
| 49 | with: |
| 50 | node-version: 22 |
| 51 | |
| 52 | - name: Install pnpm |
| 53 | uses: pnpm/action-setup@v4 |
| 54 | with: |
| 55 | package_json_file: docs/package.json |
| 56 | |
| 57 | - name: Get pnpm store directory |
| 58 | id: pnpm-cache |
| 59 | shell: bash |
| 60 | run: | |
| 61 | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 62 | |
| 63 | - name: Setup pnpm cache |
| 64 | uses: actions/cache@v4 |
| 65 | with: |
| 66 | path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 67 | key: ${{ runner.os }}-pnpm-docs-${{ hashFiles('docs/pnpm-lock.yaml') }} |
| 68 | restore-keys: | |
| 69 | ${{ runner.os }}-pnpm-docs- |
| 70 | |
| 71 | - name: Install Dependencies 📦 |
| 72 | run: pnpm install |
| 73 | |
| 74 | - name: Update Links in Markdown Files 🔄 |
| 75 | run: | |
| 76 | # Run the link update script |
| 77 | node scripts/update-links.js |
| 78 | |
| 79 | - name: Build Site 🔧 |
| 80 | run: pnpm run build |
| 81 | env: |
| 82 | GITHUB_REPOSITORY: ${{ github.repository }} |
| 83 | GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 84 | |
| 85 | - name: Upload artifact |
| 86 | uses: actions/upload-pages-artifact@v3 |
| 87 | with: |
| 88 | name: github-pages |
| 89 | path: docs/_site |
| 90 | |
| 91 | - name: Deploy to GitHub Pages |
| 92 | id: deployment |
| 93 | uses: actions/deploy-pages@v4 |
| 94 | |