Cameleer

GitHub component

The github component polls a GitHub repository for new pull requests, issues, commits, tags and events, and creates issues, comments and commit statuses through the GitHub REST API.

Scheme: github: · Crate: cameleer-saas · Cargo feature: saas · Consumer: yes · Producer: yes · Apache Camel: GitHub

When to use it

  • Greet or triage new pull requests and issues automatically (labels, first comment, review bot).
  • Let an AI agent open an issue when it finds a bug, a failed job or a security finding.
  • Feed new commits or tags into a release, deployment or changelog pipeline.
  • Read the files a pull request changes, for example to hand them to an LLM reviewer.

URI format

text
github:type[/branch]?repoOwner=owner&repoName=repo[&options]

Consumer types: pullRequest, issue, commit/<branch>, tag, event. Producer types: createIssue, pullRequestComment, issueComment, pullRequestState, pullRequestFiles, getCommitFile, closePullRequest.

Example

Comment every new pull request. The consumer sets the GitHubPullRequest header to the pull request number, so the producer knows where to comment. The first poll only records the pull requests that are already open.

yaml example: github-pr-welcome
- route:
    id: pr-welcome
    from:
      uri: "github:pullRequest?repoOwner={{env:GITHUB_OWNER:apache}}&repoName={{env:GITHUB_REPO:camel}}&oauthToken={{env:GITHUB_TOKEN}}&serverUrl={{env:GITHUB_API_URL:https://api.github.com}}&delay=30000"
      steps:
        - log: "new pull request #${header.GitHubPullRequest}: ${body[title]}"
        - setBody:
            simple: "Thanks for the pull request '${body[title]}'. A maintainer will review it soon."
        - to: "github:pullRequestComment?repoOwner={{env:GITHUB_OWNER:apache}}&repoName={{env:GITHUB_REPO:camel}}&oauthToken={{env:GITHUB_TOKEN}}&serverUrl={{env:GITHUB_API_URL:https://api.github.com}}"

An agent that files an issue. Other routes (a failed nightly job, an LLM log analyser) send the problem description to direct:file-bug; the title comes from the GitHubIssueTitle header and the body becomes the issue text. Afterwards the body is the created issue and GitHubIssue its number.

yaml example: github-agent-issue
- route:
    id: file-bug
    from:
      uri: "direct:file-bug"
      steps:
        - setHeader:
            name: GitHubIssueTitle
            simple: "Nightly job failed: ${header.job}"
        - to: "github:createIssue?repoOwner={{env:GITHUB_OWNER:apache}}&repoName={{env:GITHUB_REPO:camel}}&oauthToken={{env:GITHUB_TOKEN}}&serverUrl={{env:GITHUB_API_URL:https://api.github.com}}"
        - log: "opened issue #${header.GitHubIssue}"

Rust DSL

rust
ctx.add_routes(|b| {
    b.from("github:pullRequest?repoOwner=apache&repoName=camel&oauthToken={{env:GITHUB_TOKEN}}&delay=30000")
        .set_body(simple("Thanks for the pull request '${body[title]}'. A maintainer will review it soon."))
        .to("github:pullRequestComment?repoOwner=apache&repoName=camel&oauthToken={{env:GITHUB_TOKEN}}");
})?;

Options

optiondefaultdescription
repoOwnerRepository owner (required).
repoNameRepository name (required).
oauthTokenPersonal access token or GitHub App token, sent as a Bearer token.
startingShalastcommit consumer: last skips existing commits, beginning delivers them all, oldest first.
statepullRequestState: success, error, failure or pending (required there).
targetUrlpullRequestState: link shown with the status.
encodinggetCommitFile: base64 keeps the content base64-encoded instead of decoding it.
hookEventspush,pull_request,issuesEvents subscribed when used through webhook:github:....
serverUrlhttps://api.github.comAPI base URL (Cameleer extension: GitHub Enterprise https://ghe.example.com/api/v3, a test server).
delay, initialDelay, ...delay=10000Consumers: the standard scheduled-poll options.

eventFetchStrategy is accepted for Camel compatibility and ignored.

Message headers

headerdirectiondescription
GitHubPullRequestin / outPull request number: set by the pullRequest consumer; read by pullRequestComment, pullRequestFiles, closePullRequest.
GitHubIssuein / outIssue number: set by the issue consumer and createIssue; read by issueComment.
GitHubIssueTitleincreateIssue: the title (required).
GitHubInResponseToinpullRequestComment: reply to this review comment id.
GitHubPullRequestHeadCommitSHAinpullRequestState: commit to set the status on.
GitHubCommitSha, GitHubCommitAuthor, GitHubCommitCommitter, GitHubCommitUrloutcommit consumer (the body is the commit message).
GitHubEvent, GitHubEventId, CamelGitHubEventPayloadoutevent consumer (the body is the event type, such as PushEvent). Webhooks set GitHubEvent from X-GitHub-Event.

Run it with Docker

sh
export GITHUB_TOKEN=ghp_... GITHUB_OWNER=my-org GITHUB_REPO=my-repo
docker run --rm -e GITHUB_TOKEN -e GITHUB_OWNER -e GITHUB_REPO -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/pr-welcome.camel.yaml

Common questions

How do I get the files of a pull request for an AI review?

Send an exchange with the GitHubPullRequest header to github:pullRequestFiles: the body becomes the list of changed files (filename, status, additions, sha, ...). Split it and send each file to github:getCommitFile to get the decoded content, then to an LLM.

Can I receive webhooks instead of polling?

Yes: consume from webhook:github:pullRequest?repoOwner=...&repoName=...&oauthToken=...&webhookExternalUrl=https://ci.example.com. The repository hook is created on start and deleted on stop; the payload becomes the body.

Does the issue consumer return pull requests?

No. GitHub lists pull requests as issues, but the issue consumer filters them out. Use pullRequest for those.

How do I set a CI status on a commit?

Use github:pullRequestState?state=success&targetUrl=https://ci.example.com/run/42 with the GitHubPullRequestHeadCommitSHA header; the body becomes the status description.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub