-
Notifications
You must be signed in to change notification settings - Fork 712
76 lines (67 loc) · 2.97 KB
/
deploy-pages-previews.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Deploy Pages Previews
# This workflow is designed to deploy a "preview" version of a Pages project based on PR labels.
# Triggers:
# - update to a PR that has one of the `preview:...` labels
#
# Actions:
# - deploy the matching Pages project to Cloudflare.
#
# PR Label | Pages Project
# ---------------------------------------------------------
# preview:wrangler-devtools | packages/wrangler-devtools
# preview:quick-edit | packages/quick-edit
# preview:workers-playground | packages/workers-playground
#
# Note: this workflow does not run tests against these packages, only for deploys previews.
on:
pull_request:
types: [synchronize, opened, reopened, labeled, unlabeled]
jobs:
deploy-pages-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:wrangler-devtools') || contains(github.event.*.labels.*.name, 'preview:quick-edit') || contains(github.event.*.labels.*.name, 'preview:workers-playground'))
timeout-minutes: 60
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
node-version: 18.18
- 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:wrangler-devtools')
run: pnpm --filter @cloudflare/wrangler-devtools run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Build and Deploy Quick Edit preview
if: contains(github.event.*.labels.*.name, 'preview:quick-edit')
# Quick Edit requires yarn and VS Code build deps, so needs fairly specific logic
run: |
sudo apt-get install -y libkrb5-dev
yarn global add node-gyp
cd packages/quick-edit
yarn setup
yarn custom:build
pnpm run deploy
env:
DEBIAN_FRONTEND: noninteractive
NPM_PUBLISH_TOKEN: NOT_USED # yarn will error if the env var from .npmrc can't be interpolated
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Deploy Workers Playground preview
if: contains(github.event.*.labels.*.name, 'preview:workers-playground')
run: pnpm --filter workers-playground run build:testing && pnpm --filter workers-playground run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}