Webhooks
Push Event

Usage

import * as github from "@trigger.dev/github";

new Trigger({
  id: "demo",
  on: github.events.pushEvent({
    repo: "triggerdotdev/trigger.dev",
  }),
  run: async (event, ctx) => {},
}).listen();

Params

reporequired
string

The full path to the repository, including the organization

Event

ref
string

The full git ref that was pushed. Example: refs/heads/master.

before
string

The SHA of the commit before the push.

after
string

The SHA of the commit after the push.

created
boolean

Whether this was a created branch or tag.

deleted
boolean

Whether this was a deleted branch or tag.

forced
boolean

Whether this was a forced update or not.

base_ref
string

If the ref is a branch, this is the branch name that the push was made to.

compare
string

The HTTP URL to compare the two commits.

commits
array

An array of commit objects describing the pushed commits.

head_commit
object

The head commit object.

repositoryrequired
object

A repository on GitHub.

senderrequired
object

The GitHub user object who performed the action.

organization
object

The organization object the repository belongs to.

Example Workflows

new Trigger({
  id: "github-to-slack",
  name: "Notify of new push",
  on: github.events.pushEvent({
    repo: "triggerdotdev/trigger.dev",
  }),
  run: async (event, ctx) => {
    await slack.postMessage("New push to trigger.dev", {
      channel: "github-changes",
      text: `New push to trigger.dev by ${event.sender.login}: ${event.compare}`,
    });
  },
}).listen();

Example Event payload

{
  "ref": "refs/heads/main",
  "after": "4a0834a1daa09cdd1a03038dbc131f807d887de8",
  "before": "e7c0680e23fcd3e52d35ddfbb4076112c640d9fa",
  "forced": false,
  "pusher": {
    "name": "ericallam",
    "email": "eallam@icloud.com"
  },
  "sender": {
    "id": 534,
    "url": "https://api.github.com/users/ericallam",
    "type": "User",
    "login": "ericallam",
    "node_id": "MDQ6VXNlcjUzNA==",
    "html_url": "https://github.com/ericallam",
    "gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
    "repos_url": "https://api.github.com/users/ericallam/repos",
    "avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
    "events_url": "https://api.github.com/users/ericallam/events{/privacy}",
    "site_admin": false,
    "gravatar_id": "",
    "starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
    "followers_url": "https://api.github.com/users/ericallam/followers",
    "following_url": "https://api.github.com/users/ericallam/following{/other_user}",
    "organizations_url": "https://api.github.com/users/ericallam/orgs",
    "subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
    "received_events_url": "https://api.github.com/users/ericallam/received_events"
  },
  "commits": [
    {
      "id": "4a0834a1daa09cdd1a03038dbc131f807d887de8",
      "url": "https://github.com/triggerdotdev/trigger.dev-examples/commit/4a0834a1daa09cdd1a03038dbc131f807d887de8",
      "added": [],
      "author": {
        "name": "Eric Allam",
        "email": "eallam@icloud.com",
        "username": "ericallam"
      },
      "message": "Add some documentation for how to run (needs work)",
      "removed": [],
      "tree_id": "5c06942324e80422eea4f4c11ff80d4bd8f9d7a7",
      "distinct": true,
      "modified": [
        "README.md",
        "pnpm-lock.yaml",
        "src/examples/github-webhook.ts"
      ],
      "committer": {
        "name": "Eric Allam",
        "email": "eallam@icloud.com",
        "username": "ericallam"
      },
      "timestamp": "2023-01-24T04:43:40Z"
    }
  ],
  "compare": "https://github.com/triggerdotdev/trigger.dev-examples/compare/e7c0680e23fc...4a0834a1daa0",
  "created": false,
  "deleted": false,
  "base_ref": null,
  "repository": {
    "id": 588602633,
    "url": "https://github.com/triggerdotdev/trigger.dev-examples",
    "fork": false,
    "name": "trigger.dev-examples",
    "size": 161,
    "forks": 0,
    "owner": {
      "id": 95297378,
      "url": "https://api.github.com/users/triggerdotdev",
      "name": "triggerdotdev",
      "type": "Organization",
      "email": "hello@trigger.dev",
      "login": "triggerdotdev",
      "node_id": "O_kgDOBa4fYg",
      "html_url": "https://github.com/triggerdotdev",
      "gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
      "repos_url": "https://api.github.com/users/triggerdotdev/repos",
      "avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
      "events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
      "site_admin": false,
      "gravatar_id": "",
      "starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
      "followers_url": "https://api.github.com/users/triggerdotdev/followers",
      "following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
      "organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
      "subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
      "received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
    },
    "topics": [],
    "git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
    "license": null,
    "node_id": "R_kgDOIxVdCQ",
    "private": false,
    "ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
    "svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
    "archived": false,
    "disabled": false,
    "has_wiki": false,
    "homepage": null,
    "html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
    "keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
    "language": "TypeScript",
    "tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
    "watchers": 1,
    "blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
    "clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
    "forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
    "full_name": "triggerdotdev/trigger.dev-examples",
    "has_pages": false,
    "hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
    "pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
    "pushed_at": 1674535423,
    "teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
    "trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
    "created_at": 1673620005,
    "events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
    "has_issues": true,
    "issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
    "labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
    "merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
    "mirror_url": null,
    "stargazers": 1,
    "updated_at": "2023-01-23T14:22:40Z",
    "visibility": "public",
    "archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
    "commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
    "compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
    "description": "Node.js project with multiple example Trigger.dev workflows",
    "forks_count": 0,
    "is_template": false,
    "open_issues": 2,
    "branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
    "comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
    "contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
    "git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
    "git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
    "has_projects": true,
    "organization": "triggerdotdev",
    "releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
    "statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
    "allow_forking": true,
    "assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
    "downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
    "has_downloads": false,
    "languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
    "master_branch": "main",
    "default_branch": "main",
    "milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
    "stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
    "watchers_count": 1,
    "deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
    "git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
    "has_discussions": false,
    "subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
    "contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
    "issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
    "stargazers_count": 1,
    "subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
    "collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
    "issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
    "notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
    "open_issues_count": 2,
    "web_commit_signoff_required": false
  },
  "head_commit": {
    "id": "4a0834a1daa09cdd1a03038dbc131f807d887de8",
    "url": "https://github.com/triggerdotdev/trigger.dev-examples/commit/4a0834a1daa09cdd1a03038dbc131f807d887de8",
    "added": [],
    "author": {
      "name": "Eric Allam",
      "email": "eallam@icloud.com",
      "username": "ericallam"
    },
    "message": "Add some documentation for how to run (needs work)",
    "removed": [],
    "tree_id": "5c06942324e80422eea4f4c11ff80d4bd8f9d7a7",
    "distinct": true,
    "modified": [
      "README.md",
      "pnpm-lock.yaml",
      "src/examples/github-webhook.ts"
    ],
    "committer": {
      "name": "Eric Allam",
      "email": "eallam@icloud.com",
      "username": "ericallam"
    },
    "timestamp": "2023-01-24T04:43:40Z"
  },
  "organization": {
    "id": 95297378,
    "url": "https://api.github.com/orgs/triggerdotdev",
    "login": "triggerdotdev",
    "node_id": "O_kgDOBa4fYg",
    "hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
    "repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
    "avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
    "events_url": "https://api.github.com/orgs/triggerdotdev/events",
    "issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
    "description": "",
    "members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
    "public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}"
  }
}