microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
.github/workflows/deploy-pages.yml
118lines · 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 | |
| 45 | - name: Get User Permission |
| 46 | id: checkAccess |
| 47 | uses: actions-cool/check-user-permission@v2 |
| 48 | with: |
| 49 | require: write |
| 50 | username: ${{ github.triggering_actor }} |
| 51 | env: |
| 52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | - name: Check User Permission |
| 54 | if: steps.checkAccess.outputs.require-result == 'false' |
| 55 | run: | |
| 56 | echo "${{ github.triggering_actor }} does not have permissions on this repo." |
| 57 | echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" |
| 58 | echo "Job originally triggered by ${{ github.actor }}" |
| 59 | exit 1 |
| 60 | |
| 61 | - name: Checkout Repository 🛎️ |
| 62 | uses: actions/checkout@v3 |
| 63 | with: |
| 64 | ref: ${{ github.event.pull_request.head.sha }} |
| 65 | fetch-depth: 0 |
| 66 | |
| 67 | - name: Check Repository Structure |
| 68 | run: | |
| 69 | echo "Repository root contents:" |
| 70 | ls -la |
| 71 | working-directory: . |
| 72 | |
| 73 | - name: Setup Node.js ⚙️ |
| 74 | uses: actions/setup-node@v3 |
| 75 | with: |
| 76 | node-version: 18.x |
| 77 | |
| 78 | - name: Install pnpm |
| 79 | uses: pnpm/action-setup@v2 |
| 80 | with: |
| 81 | version: 8 |
| 82 | run_install: false |
| 83 | |
| 84 | - name: Get pnpm store directory |
| 85 | id: pnpm-cache |
| 86 | shell: bash |
| 87 | run: | |
| 88 | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 89 | |
| 90 | - name: Setup pnpm cache |
| 91 | uses: actions/cache@v3 |
| 92 | with: |
| 93 | path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 94 | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 95 | restore-keys: | |
| 96 | ${{ runner.os }}-pnpm-store- |
| 97 | |
| 98 | - name: Install Dependencies 📦 |
| 99 | run: pnpm install |
| 100 | |
| 101 | - name: Update Links in Markdown Files 🔄 |
| 102 | run: | |
| 103 | # Run the link update script |
| 104 | node scripts/update-links.js |
| 105 | |
| 106 | - name: Build Site 🔧 |
| 107 | run: pnpm run build |
| 108 | env: |
| 109 | GITHUB_REPOSITORY: ${{ github.repository }} |
| 110 | GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 111 | |
| 112 | - name: Upload artifact |
| 113 | uses: actions/upload-pages-artifact@v3 |
| 114 | with: |
| 115 | name: github-pages |
| 116 | path: docs/_site |
| 117 | - name: Deploy to GitHub Pages from artifacts |
| 118 | uses: actions/deploy-pages@v4 |
| 119 | |