mirror of
https://github.com/cloudflare/cloudflare-docs.git
synced 2026-01-11 20:06:58 +00:00
59 lines
1.6 KiB
YAML
59 lines
1.6 KiB
YAML
on:
|
|
push:
|
|
branches-ignore:
|
|
- production
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-22.04
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
name: Publish Preview
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22.x
|
|
cache: npm
|
|
- run: npm ci
|
|
- uses: actions/cache/restore@v4
|
|
with:
|
|
path: |
|
|
node_modules/.astro
|
|
key: static
|
|
- run: npm run build
|
|
name: Build
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=4096
|
|
- run: npx wrangler versions upload
|
|
name: Deploy to Cloudflare Workers
|
|
env:
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
WRANGLER_OUTPUT_FILE_PATH: wrangler-logs.json
|
|
- name: Post preview URL on PR
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
PR=$(gh pr list --head ${{ github.ref_name }} --limit 1 --json number --jq '.[].number')
|
|
|
|
if [ -n "$PR" ]; then
|
|
URL=$(cat wrangler-logs.json | jq -r 'select(.type=="version-upload") | .preview_url')
|
|
|
|
if [ -n "$URL" ]; then
|
|
BODY="**Preview URL:** $URL"
|
|
gh pr comment "$PR" --edit-last --body "$BODY" || gh pr comment "$PR" --body "$BODY"
|
|
fi
|
|
fi
|
|
- uses: actions/cache/save@v4
|
|
if: always()
|
|
with:
|
|
path: |
|
|
node_modules/.astro
|
|
key: static
|