These are the docs for Trigger.dev v2 which will be deprecated on January 31st, 2025. You probably want the v3 docs.

You can use these triggers to start a job when a GitHub event occurs.


Repo

Repo triggers subscribe to a change in a GitHub repo.

github.triggers.repo({
  event: events.onIssueOpened,
  owner: "triggerdotdev",
  repo: "trigger.dev",
});
options
object

Org

Org triggers subscribe to a change across an entire GitHub org.

github.triggers.repo({
  event: events.onIssueOpened,
  owner: "triggerdotdev",
});
options
object

Events

onIssue

When any action is performed on an issue. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onIssue,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

onIssueOpened

Occurs when an issue is opened. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.org({
    event: events.onIssueOpened,
    owner: "<my-github-org-name>",
  }),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

onIssueAssigned

When an issue is assigned. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onAssigned,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    // Add tasks here
  },
});

onIssueComment

When an issue is commented on. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onIssueComment,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onStar

When a repo is starred or unstarred. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onStar,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onNewStar

When a repo is starred. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onNewStar,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onNewRepository

When a new repo is created. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onNewRepository,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onNewBranchOrTag

When a new branch or tag is created. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onNewBranchOrTag,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onNewBranch

When a new branch is created. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onNewBranch,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onPush

When a push is made to a repo. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onPush,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onPullRequest

When activity occurs on a pull request (excluding reviews, issues, or comments). Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onPullRequest,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});

onPullRequestReview

When a pull request review has activity. Official GitHub docs.

usage.ts
client.defineJob({
  id: "<my-id>",
  name: "<my-job-name>",
  version: "0.1.0",
  trigger: github.triggers.repo({
    event: events.onPullRequestReview,
    owner: "<my-github-org-name>",
    repo: "<my-github-repo>",
  }),
  run: async (payload, io, ctx) => {
    //  Add tasks here
  },
});