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