Deploy Docs Preview #1473
This file contains 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: Deploy Docs Preview | |
on: | |
workflow_run: | |
workflows: ['CI'] | |
branches: [master] | |
types: [completed] | |
pull_request: | |
branches: [master] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DOCS_CLOUDFLARE_DEPLOYMENT: true | |
jobs: | |
check: | |
name: Build and deploy Docs | |
runs-on: ubuntu-latest | |
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'pnpm' | |
- run: pnpm install | |
- run: pnpm docs:build | |
- name: Deploy vitepress docs | |
id: deploy-docs | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
accountId: ${{ secrets.CF_ACCOUNT_ID || secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CF_API_TOKEN || secrets.CLOUDFLARE_API_TOKEN }} | |
packageManager: 'pnpm' | |
command: pages deploy docs/.vitepress/dist/ --project-name=cloudflare-turbo-cache-docs | |
- name: Comment with deploy link | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const deploymentUrl = process.env.DEPLOYMENT_URL; | |
const commitHash = context.payload.pull_request.head.sha; | |
const status = '✅ Deploy successful!' | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ` | |
# 🌩 Deploying with Cloudflare Pages | |
| Name | Result | | |
| ----------------------- | ------ | | |
| **Last commit:** | \`${commitHash.substring(0, 7)}\` | | |
| **Status**: | ${status} | | |
| **Preview URL**: | ${deploymentUrl} | | |
` | |
}); | |
env: | |
DEPLOYMENT_URL: ${{ steps.deploy-docs.outputs.deployment-url }} |