Skip to content

Add external scheduler examples for cloud platforms#89

Open
ezzatron wants to merge 23 commits into
mainfrom
external-scheduler
Open

Add external scheduler examples for cloud platforms#89
ezzatron wants to merge 23 commits into
mainfrom
external-scheduler

Conversation

@ezzatron
Copy link
Copy Markdown
Member

@ezzatron ezzatron commented May 18, 2026

Adds ready-to-deploy external scheduler examples for Cloudflare Workers, AWS Lambda, GCP Cloud Run, and Azure Functions. Each triggers the token-provider workflow via workflow_dispatch on a 30-minute schedule using GitHub App auth through the octokit package.

What's included

  • Core dispatch module (src/external-scheduler/dispatch.ts) — shared logic using octokit's App class for auth, retry, and throttling; validates repo format and resolves the default branch via the API
  • Platform entrypoints — thin adapters for each cloud platform's handler signature
  • Platform secret stores — each platform stores the GitHub App private key in its native secret manager (AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, Cloudflare Workers Secrets)
  • Build pipeline — esbuild bundles committed as generated files, verified by make precommit
  • Platform configs — wrangler.toml, SAM template with SAR metadata, ARM template with Key Vault, Dockerfile for Cloud Run, host.json, Azure Functions v4 registration
  • Documentation — per-platform READMEs with deploy instructions and click-to-deploy buttons
  • ADR 0031 — captures the decision to use octokit App rather than manual JWT/retry

Motivation

GitHub Actions cron schedules are unreliable — runs can be delayed or skipped. Users need an external scheduler to guarantee at least one successful workflow dispatch per hour.

ezzatron and others added 10 commits May 18, 2026 23:10
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use octokit's App client to discover the installation for a
repository and dispatch the configured workflow.

Add unit tests that mock the octokit module and cover the
expected request flow, 404 handling, and error propagation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add thin Cloudflare, AWS, GCP, and Azure wrappers around\nexternal dispatch(). Each entrypoint reads platform config\nfrom bindings or environment variables and forwards it to\nthe shared dispatcher.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a build script and Makefile integration for the external\nscheduler example bundles. Also ignore those generated dist\ndirectories in ESLint so precommit can verify generated files\nwithout linting bundle output.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ca32864) to head (30e2b17).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #89   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           44        49    +5     
  Lines         1210      1265   +55     
  Branches       283       293   +10     
=========================================
+ Hits          1210      1265   +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds external scheduler examples that dispatch the token-provider workflow from serverless schedulers across major cloud platforms, with shared Octokit-based GitHub App authentication and generated deployment bundles.

Changes:

  • Introduces shared workflow dispatch logic plus AWS, Azure, GCP, and Cloudflare scheduler entrypoints with unit tests.
  • Adds build and generated-file verification wiring for external scheduler bundles.
  • Adds platform deployment docs/configuration and an ADR for using Octokit App authentication.

Reviewed changes

Copilot reviewed 26 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tsconfig.json Excludes generated/example deployment artifacts from project typechecking.
src/external-scheduler/dispatch.ts Adds shared GitHub App workflow dispatch implementation.
src/external-scheduler/dispatch.spec.ts Tests dispatch authentication, installation lookup, and workflow dispatch behavior.
src/external-scheduler/aws/index.ts Adds AWS Lambda scheduler handler.
src/external-scheduler/aws/index.spec.ts Tests AWS handler environment parsing and dispatch calls.
src/external-scheduler/azure/index.ts Adds Azure timer trigger handler.
src/external-scheduler/azure/index.spec.ts Tests Azure handler environment parsing and dispatch calls.
src/external-scheduler/gcp/index.ts Adds GCP Cloud Function handler.
src/external-scheduler/gcp/index.spec.ts Tests GCP handler environment parsing and dispatch calls.
src/external-scheduler/cloudflare/index.ts Adds Cloudflare scheduled Worker handler.
src/external-scheduler/cloudflare/index.spec.ts Tests Cloudflare env binding dispatch behavior.
script/build-external-schedulers.ts Adds esbuild bundling for all scheduler examples.
Makefile Registers scheduler bundles as generated files.
eslint.config.js Ignores generated scheduler bundle directories.
.prettierignore Ignores generated example bundle directories.
examples/external-scheduler/README.md Adds top-level external scheduler guide.
examples/external-scheduler/aws-lambda/README.md Adds AWS Lambda deployment guide.
examples/external-scheduler/aws-lambda/template.yaml Adds SAM/EventBridge scheduler configuration.
examples/external-scheduler/azure-function/README.md Adds Azure Functions deployment guide.
examples/external-scheduler/azure-function/function.json Adds Azure timer trigger binding.
examples/external-scheduler/azure-function/host.json Adds Azure Functions host configuration.
examples/external-scheduler/gcp-cloud-function/README.md Adds GCP Cloud Function and Cloud Scheduler guide.
examples/external-scheduler/gcp-cloud-function/package.json Adds package metadata for GCP deployment.
examples/external-scheduler/cloudflare-worker/README.md Adds Cloudflare Worker deployment guide.
examples/external-scheduler/cloudflare-worker/package.json Adds package metadata for Cloudflare example.
examples/external-scheduler/cloudflare-worker/wrangler.toml Adds Worker cron trigger and environment config.
docs/adrs/0031-use-octokit-app-for-external-scheduler-dispatch.md Documents the Octokit App authentication decision.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/external-scheduler/dispatch.ts Outdated
Comment thread src/external-scheduler/dispatch.ts Outdated
Comment thread examples/external-scheduler/aws-lambda/template.yaml
Comment thread examples/external-scheduler/azure-function/README.md Outdated
Comment thread examples/external-scheduler/gcp-cloud-function/README.md Outdated
Comment thread examples/external-scheduler/aws-lambda/README.md Outdated
ezzatron and others added 9 commits May 19, 2026 17:05
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The dispatch function now validates that the repo string is exactly
owner/repo format before making API calls, and resolves the target
repository's default branch instead of hard-coding 'main'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refactor HTTP handler to avoid async callback in createServer.
Update GCP Cloud Function reference to Cloud Run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AWS: fetch from Secrets Manager at runtime. Template creates the
secret resource with IAM policy; user populates post-deploy.

Azure: ARM template creates Key Vault with RBAC, assigns the
Function App's managed identity the Secrets User role, and uses a
Key Vault reference in app settings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 41 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread src/external-scheduler/gcp/index.spec.ts Outdated
Comment thread Makefile Outdated
Comment thread docs/superpowers/specs/2026-05-19-deploy-button-fixes-design.md Outdated
Comment thread docs/superpowers/plans/2026-05-19-deploy-button-fixes.md Outdated
Comment thread src/external-scheduler/gcp/index.ts Outdated
- Fix Makefile rule target (gcp-cloud-function → gcp-cloud-run)
- Restrict GCP endpoint to POST requests (405 otherwise)
- Use vi.hoisted() for mockListen in GCP spec
- Add test for non-Error rejection and method check
- Delete ephemeral docs/superpowers/ plan and spec files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 39 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread examples/external-scheduler/azure-function/function.json Outdated
Replace function.json timer binding with app.timer() registration
from @azure/functions v4. Delete function.json (no longer needed),
add package.json with main entry, mark @azure/functions as external
in the esbuild config since the runtime provides it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 39 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread examples/external-scheduler/azure-function/README.md Outdated
Comment thread examples/external-scheduler/azure-function/package.json Outdated
Comment thread examples/external-scheduler/aws-lambda/template.yaml
Add @azure/functions dependency to Azure package.json so the
external import resolves at runtime. Update README to reference
code-based timer registration instead of deleted function.json.
Add CodeUri to AWS SAM template so sam deploy packages the bundle.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 39 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants