Skip to content

Commit 0f65a89

Browse files
committed
Updates.
1 parent 0b8c640 commit 0f65a89

3 files changed

Lines changed: 64 additions & 81 deletions

File tree

README.md

Lines changed: 62 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ You must:
9191

9292
- Use Wrangler v4 (Versions API support required).
9393
- Ensure you have a reliable way to invoke Wrangler v4:
94-
- - You specify this explicitly via the `wrangler_command` input.
95-
- - Examples:
96-
- - `wrangler`
97-
- - `npx wrangler@4`
98-
- - `pnpm dlx wrangler@4`
99-
- - No separate install step is required if your `wrangler_command` handles it.
94+
- You specify this explicitly via the `wrangler_command` input.
95+
- Examples:
96+
- `wrangler`
97+
- `npx wrangler@4`
98+
- `pnpm dlx wrangler@4`
99+
- No separate install step is required if your `wrangler_command` handles it.
100100
- Provide a Cloudflare API token:
101101
- With appropriate permissions for your Worker.
102102
- Passed via `secrets` to the `api_token` input.
@@ -109,6 +109,7 @@ You must:
109109
This Action does NOT:
110110

111111
- Build your project.
112+
- Install wrangler for you.
112113
- Infer your Wrangler config automatically.
113114
- Manage `account_id` for you (Wrangler should pick that up from config/env).
114115

@@ -126,11 +127,8 @@ All inputs are strings (as per GitHub Actions) unless noted; booleans are passed
126127
- This is the base command (and optional leading arguments) that will be used for both upload and deploy.
127128
- Examples:
128129
- `wrangler`
129-
- `npx wrangler@4`
130+
- `npx wrangler`
130131
- `pnpm dlx wrangler@4`
131-
- The Action splits this into:
132-
- Executable: first token
133-
- Base args: remaining tokens
134132
- Then runs:
135133
- `<wrangler_command> versions upload ...`
136134
- `<wrangler_command> versions deploy ...`
@@ -142,13 +140,14 @@ All inputs are strings (as per GitHub Actions) unless noted; booleans are passed
142140
- `versions deploy`
143141
- Useful for monorepos where your Worker lives in a subfolder.
144142

145-
- `config` (required)
143+
- `config` (optional)
146144
- Path to the Wrangler configuration file.
147-
- Passed as:
148-
- `--config <config>`
149-
- Applied to both:
150-
- `wrangler versions upload`
151-
- `wrangler versions deploy`
145+
- When provided:
146+
- Passed as `--config <config>` to both:
147+
- `wrangler versions upload`
148+
- `wrangler versions deploy`
149+
- When omitted:
150+
- Wrangler's default configuration resolution is used (for example, a `wrangler.toml` in the working directory).
152151

153152
- `upload_args` (optional)
154153
- Extra arguments for:
@@ -267,7 +266,8 @@ jobs:
267266
with:
268267
api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
269268
wrangler_command: "pnpm dlx wrangler@4"
270-
config: "dist/server/wrangler.json"
269+
working_directory: "dist/server"
270+
config: "wrangler.json"
271271
upload_args: "--env production"
272272
deploy_args: "--env production"
273273
message_template: "Deployed {{repo}}@{{short_sha}} to {{branch}} by {{actor}} (run {{run_number}})"
@@ -306,6 +306,7 @@ jobs:
306306
with:
307307
api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
308308
wrangler_command: "pnpm dlx wrangler@4"
309+
working_directory: "."
309310
config: "wrangler.toml"
310311
upload_args: "--env staging"
311312
only_upload: "true"
@@ -353,69 +354,51 @@ You can combine outputs with other Actions to post deployment info back to PRs:
353354
].filter(Boolean).join("\n")
354355
});
355356
```
356-
+
357+
357358
### Example 4: Monorepo - Deploy Only When a Folder Changes
358-
+
359-
+In a monorepo, you often want to:
360-
+
361-
+- Only run builds/deploys when a specific app/package directory changes.
362-
+- Use a config file that lives within that directory.
363-
+
364-
+This example:
365-
+
366-
+- Triggers only when files under `apps/worker-app/` change.
367-
+- Uses the Wrangler config at `apps/worker-app/wrangler.toml`.
368-
+- Builds and deploys only that app.
369-
+
370-
+```yaml
371-
+name: Deploy Worker App (Monorepo)
372-
+
373-
+on:
374-
+ push:
375-
+ branches: [main]
376-
+ paths:
377-
+ - "apps/worker-app/**"
378-
+
379-
+jobs:
380-
+ deploy-worker-app:
381-
+ runs-on: ubuntu-latest
382-
+ defaults:
383-
+ run:
384-
+ working-directory: apps/worker-app
385-
+
386-
+ steps:
387-
+ - uses: actions/checkout@v4
388-
+
389-
+ # Install and build only this app
390-
+ # - run: pnpm install
391-
+ # - run: pnpm build
392-
+
393-
+ - run: pnpm dlx wrangler@4 --version
394-
+
395-
- name: Upload + deploy worker-app via Versions API with metadata
396-
id: cf_deploy
397-
uses: your-org/wrangler-version-deploy-action-with-metadata@v1
398-
with:
399-
api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
400-
wrangler_command: "pnpm dlx wrangler@4"
401-
working_directory: "apps/worker-app"
402-
config: "wrangler.toml"
403-
upload_args: "--env production"
404-
deploy_args: "--env production"
405-
message_template: "worker-app: {{repo}}@{{short_sha}} on {{branch}} (run {{run_number}})"
406-
```
407359

408-
## Notes
360+
In a monorepo, you often want to:
361+
362+
- Only run builds/deploys when a specific app/package directory changes.
363+
- Use a config file that lives within that directory.
409364

410-
- This Action focuses on being:
411-
- Explicit about config (`config` input).
412-
- Clear about which args go to upload vs deploy.
413-
- Purpose-built for Wrangler v4’s Versions API.
414-
- If Wrangler’s output format changes:
415-
- `deployment_url` parsing is best-effort.
416-
- `version_id` parsing is based on the standard `Worker Version ID:` line.
417-
- For GitHub Marketplace:
418-
- Reference it as `your-org/wrangler-version-deploy-action-with-metadata@v1`.
419-
- Keep a `v1` tag pointing at the latest stable release.
365+
This example:
366+
367+
- Triggers only when files under `apps/worker-app/` change.
368+
- Uses the Wrangler config at `apps/worker-app/wrangler.toml`.
369+
- Builds and deploys only that app.
370+
371+
```yaml
372+
name: Deploy Worker App (Monorepo)
420373

421-
If you have real Wrangler output samples and want to harden the parsing further, you can refine this Action’s internals without changing the public interface described here.
374+
on:
375+
push:
376+
branches: [main]
377+
paths:
378+
- "apps/worker-app/**"
379+
380+
jobs:
381+
deploy-worker-app:
382+
runs-on: ubuntu-latest
383+
defaults:
384+
run:
385+
working-directory: apps/worker-app
386+
387+
steps:
388+
- uses: actions/checkout@v4
389+
390+
# Install and build only this app
391+
# - run: pnpm install
392+
# - run: pnpm build
393+
394+
name: Upload + deploy worker-app via Versions API with metadata
395+
id: cf_deploy
396+
uses: your-org/wrangler-version-deploy-action-with-metadata@v1
397+
with:
398+
api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
399+
wrangler_command: "pnpm dlx wrangler@4"
400+
working_directory: "apps/worker-app"
401+
config: "wrangler.toml"
402+
upload_args: "--env production"
403+
deploy_args: "--env production"
404+
message_template: "worker-app: {{repo}}@{{short_sha}} on {{branch}} (run {{run_number}})"

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "Wrangler Version Deploy Action with Metadata"
22
description: "Deploy Cloudflare Workers/Pages using Wrangler v4 with customizable messages and tags derived from GitHub metadata."
3-
author: "neighbor"
3+
author: "Chris Ewald"
44
branding:
55
icon: "cloud"
66
color: "orange"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ci",
1919
"cd"
2020
],
21-
"author": "neighbor",
21+
"author": "Chris Ewald",
2222
"license": "MIT",
2323
"dependencies": {
2424
"@actions/core": "^1.11.1",

0 commit comments

Comments
 (0)