[pull] main from cloudflare:main #322
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: Deploy Previews | |
| # This workflow is designed to deploy a "preview" version of a project based on PR labels. | |
| # Triggers: | |
| # - update to a PR that has one of the `preview:...` labels | |
| # | |
| # Actions: | |
| # - deploy the matching project to Cloudflare. | |
| # | |
| # PR Label | Project | |
| # --------------------------------------------------------- | |
| # preview:chrome-devtools-patches | packages/chrome-devtools-patches | |
| # preview:quick-edit | packages/quick-edit | |
| # | |
| # Note: this workflow does not run tests against these packages, only deploys previews. | |
| on: | |
| pull_request: | |
| types: [synchronize, opened, reopened, labeled, unlabeled] | |
| permissions: | |
| contents: read | |
| # pull-request:write permission needed so that the workflow can comment on PRs | |
| pull-requests: write | |
| jobs: | |
| deploy-projects: | |
| # Only run this on PRs that are for the "cloudflare" org and not "from" `main` | |
| # - non-Cloudflare PRs will not have the secrets needed | |
| # - PRs "from" main would accidentally do a production deployment | |
| if: github.repository_owner == 'cloudflare' && github.head_ref != 'main' && (contains(github.event.*.labels.*.name, 'preview:chrome-devtools-patches') || contains(github.event.*.labels.*.name, 'preview:quick-edit')) | |
| timeout-minutes: 60 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-app-previews | |
| runs-on: macos-latest-large | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Install Dependencies | |
| uses: ./.github/actions/install-dependencies | |
| - name: Build tools and libraries | |
| run: pnpm run build | |
| env: | |
| NODE_ENV: "production" | |
| CI_OS: ${{ runner.os }} | |
| - name: Deploy Wrangler DevTools preview | |
| if: contains(github.event.*.labels.*.name, 'preview:chrome-devtools-patches') | |
| run: | | |
| output=$(pnpm --filter @cloudflare/chrome-devtools-patches run deploy:preview) | |
| echo "Command output: $output" | |
| echo "Extracting deployed URL from command output" | |
| url=$(echo "$output" | sed -nE "s/.*Version Preview URL: ([^[:space:]]+).*/\1/p") | |
| echo "Extracted URL: $url" | |
| echo "VITE_DEVTOOLS_PREVIEW_URL=$url" >> $GITHUB_ENV | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| - name: Build and Deploy Quick Edit preview | |
| if: contains(github.event.*.labels.*.name, 'preview:quick-edit') | |
| run: pnpm --filter quick-edit run preview | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| NODE_OPTIONS: "--max_old_space_size=30000" | |
| - name: "Comment on PR with Devtools Link" | |
| if: contains(github.event.*.labels.*.name, 'preview:chrome-devtools-patches') | |
| uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2 | |
| with: | |
| header: chrome-devtools-preview | |
| message: | | |
| The Wrangler DevTools preview is now live. You can access it directly at: ${{ env.VITE_DEVTOOLS_PREVIEW_URL }}/js_app | |
| In order to test the DevTools preview in `wrangler`: | |
| 1. `npx wrangler dev`. | |
| 2. Hit `d` to open the DevTools in a fresh browser window. | |
| 3. Paste the DevTools preview URL into the address bar (keeping all existing query parameters), e.g: | |
| ``` | |
| - https://devtools.devprod.cloudflare.dev/js_app?theme=systemPreferred&ws=127.0.0.1%3A9229%2Fws&domain=tester&debugger=true | |
| + ${{ env.VITE_DEVTOOLS_PREVIEW_URL }}/js_app?theme=systemPreferred&ws=127.0.0.1%3A9229%2Fws&domain=tester&debugger=true | |
| ``` |