docs: token guides #85
Workflow file for this run
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: Preview Documentation | |
| on: | |
| pull_request: | |
| paths: | |
| - "docs/**" | |
| permissions: | |
| contents: read | |
| env: | |
| # Among other things, opts out of Turborepo telemetry | |
| # See https://consoledonottrack.com/ | |
| DO_NOT_TRACK: "1" | |
| NEXT_TELEMETRY_DISABLED: "1" | |
| VERCEL_TELEMETRY_DISABLED: "1" | |
| # Some tasks slow down considerably on GitHub Actions runners when concurrency is high | |
| TURBO_CONCURRENCY: 1 | |
| # Enables Turborepo Remote Caching. | |
| TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} | |
| TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
| TURBO_TEAM: ${{ vars.TURBO_TEAM }} | |
| jobs: | |
| preview-docs: | |
| if: github.actor != 'dependabot[bot]' | |
| permissions: | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| name: Build Documentation Preview | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Dependencies | |
| uses: ./.github/workflows/actions/install-dependencies | |
| - name: Install Isolated Docs Dependencies | |
| working-directory: ./docs/ | |
| shell: bash | |
| run: pnpm install --ignore-workspace | |
| - name: Install Vercel CLI | |
| run: pnpm install -g vercel | |
| - name: Deploy to Vercel | |
| shell: bash | |
| id: vercel_deploy | |
| env: | |
| BRANCH_NAME: ${{ github.head_ref }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| run: | | |
| vercel pull --token="$VERCEL_TOKEN" --yes --environment=preview | |
| vercel build --token="$VERCEL_TOKEN" --target=preview | |
| DEPLOY_OUTPUT=$(vercel deploy --token="$VERCEL_TOKEN" --archive=tgz --env GITHUB_PR_NUMBER="$PR_NUMBER" --env GITHUB_PR_BRANCH="$BRANCH_NAME" --prebuilt --target=preview 2>&1) | |
| DEPLOY_EXIT_CODE=$? | |
| if [ $DEPLOY_EXIT_CODE -ne 0 ]; then | |
| echo "Vercel deploy failed:" | |
| echo "$DEPLOY_OUTPUT" | |
| exit $DEPLOY_EXIT_CODE | |
| fi | |
| DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep -o 'https://[a-zA-Z0-9.-]*\.vercel\.app' | tail -1) | |
| echo "preview_url=$DEPLOY_URL" >> $GITHUB_OUTPUT | |
| - name: Comment on PR with Preview URL | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| PREVIEW_URL: "${{ steps.vercel_deploy.outputs.preview_url }}" | |
| run: | | |
| gh pr comment $PR_NUMBER --body "Documentation Preview: $PREVIEW_URL" --create-if-none --edit-last |