Skip to content

GCP Job RunnerDefine once, run anywhere

Schema-driven CLI jobs that run locally during development and on Cloud Run in production. Same code, same secrets, same behavior.

Quick Look

Define a job with a Zod schema:

typescript
import { z } from "zod";
import { defineJob } from "gcp-job-runner";

export default defineJob({
  description: "Count down and exit",
  schema: z.object({
    seconds: z.number().default(10).describe("Number of seconds to count down"),
  }),
  handler: async ({ seconds }) => {
    for (let i = seconds; i > 0; i--) {
      console.log(`${i}...`);
      await new Promise((resolve) => setTimeout(resolve, 1000));
    }
    console.log("Done!");
  },
});

Run it locally:

bash
job local run stag countdown --seconds 5

Run it on Cloud Run:

bash
job cloud run stag countdown --seconds 5

The cloud command builds a Docker image, pushes it to Artifact Registry, and streams logs back to your terminal. Images are cached by content hash — if your code hasn't changed, there's no rebuild, no deploy, straight to execution.

Released under the MIT License.