Skip to content

Commit 02f7b35

Browse files
authored
[codex] Deploy guide worker (#1302)
* ci: deploy guide worker * chore: format api data * ci: comment guide deployments * fix: deploy guide previews as worker versions * chore: ignore generated api data formatting
1 parent ab63b6e commit 02f7b35

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,61 @@ jobs:
8080
8181
${{ steps.deploy.outputs.command-output }}
8282
83+
deploy-guide:
84+
runs-on: ubuntu-latest
85+
name: Deploy Guide Worker
86+
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]' }}
87+
permissions:
88+
contents: read
89+
deployments: write
90+
pull-requests: write
91+
steps:
92+
- uses: actions/checkout@v6.0.2
93+
- name: Setup Node.js environment
94+
uses: actions/setup-node@v6.3.0
95+
with:
96+
node-version-file: ".node-version"
97+
cache: "yarn"
98+
- name: Enable Corepack
99+
run: corepack enable
100+
- name: Install dependencies
101+
run: yarn install
102+
- name: Build guide
103+
run: yarn build:guide
104+
- name: Set guide deployment command
105+
shell: bash
106+
run: |
107+
RAW_BRANCH="${{ github.head_ref || github.ref_name }}"
108+
SAFE_BRANCH=$(echo "$RAW_BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9-]+/-/g; s/^-+//; s/-+$//; s/-+/-/g')
109+
SAFE_BRANCH="${SAFE_BRANCH:0:28}"
110+
111+
if [[ "${{ github.event_name }}" == "push" && "$RAW_BRANCH" == "master" ]] || [[ "${{ inputs.environment }}" == "production" ]]; then
112+
echo "GUIDE_DEPLOY_COMMAND=deploy" >> "$GITHUB_ENV"
113+
else
114+
echo "GUIDE_DEPLOY_COMMAND=versions upload --preview-alias=$SAFE_BRANCH" >> "$GITHUB_ENV"
115+
fi
116+
- name: Deploy guide
117+
id: deploy-guide
118+
uses: cloudflare/wrangler-action@v3
119+
with:
120+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
121+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
122+
workingDirectory: apps/guide
123+
command: ${{ env.GUIDE_DEPLOY_COMMAND }}
124+
wranglerVersion: 4.85.0
125+
env:
126+
FORCE_COLOR: 0
127+
- name: Comment PR with guide deployment link
128+
if: ${{ github.event_name == 'pull_request' }}
129+
uses: marocchino/sticky-pull-request-comment@v2
130+
with:
131+
recreate: true
132+
header: guide-deployment
133+
message: |
134+
## Guide Cloudflare deployment
135+
136+
${{ steps.deploy-guide.outputs.command-output }}
137+
83138
e2e:
84139
runs-on: ubuntu-latest
85140
name: E2E Tests

.oxfmtrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"*.swp",
1414
"apps/docs/app/**/*.mjs",
1515
"build",
16+
"data/api/**/*.json",
1617
"apps/docs/data/api/**/*.json",
1718
"dist",
1819
"apps/docs/index_data/*.json",

apps/guide/wrangler.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name = "guide"
2+
compatibility_date = "2026-05-20"
3+
workers_dev = true
4+
5+
[assets]
6+
directory = "./out"
7+
not_found_handling = "single-page-application"

0 commit comments

Comments
 (0)