Skip to content

GCP Job RunnerFocus on the job

A CLI tool to run scripts locally or on Cloud Run. Simple code, zero boilerplate.

Quick Look

GCP Job Runner gives you a CLI to define, discover, and execute jobs from your terminal. Write your logic as a simple function, and run it against any environment — locally on your machine or remotely on Cloud Run — with a single command.

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.

For a more realistic example, see the database migration example — a Firestore migration job that demonstrates idempotent updates, pagination, and environment targeting.

Released under the MIT License.