| Crates.io | octofer |
| lib.rs | octofer |
| version | 0.1.0 |
| created_at | 2025-09-19 08:36:44.34501+00 |
| updated_at | 2025-10-07 14:29:27.104547+00 |
| description | A framework for building GitHub Apps in Rust |
| homepage | |
| repository | https://github.com/AbelHristodor/octofer |
| max_upload_size | |
| id | 1846040 |
| size | 1,783,030 |
A framework for building GitHub Apps, in Rust
⚠️ Under Development - This framework is currently in active development and may have bugs and issues.
A framework for building GitHub Apps in Rust, inspired by Probot. Octofer provides a clean, type-safe way to build GitHub Apps with minimal boilerplate and automatic webhook handling.
Octofer simplifies GitHub App development by:
🛠️ Looking for a full production-ready example? Check out frezze! A bot that you can use to schedule "freeze" periods for your repo, blocking all PR merges for specific periods of time!
GitHub webhook events supported by Octofer (depends on octocrab):
on_issue() - Issue events (opened, closed, edited, etc.)on_issue_comment() - Issue comment events (created, edited, deleted)on_pull_request() - Pull request events (opened, closed, merged, etc.)on_pull_request_review() - Pull request review eventson_pull_request_review_comment() - Pull request review comment eventson_pull_request_review_thread() - Pull request review thread eventson_push() - Push eventson_create() - Branch/tag createdon_delete() - Branch/tag deletedon_fork() - Repository forkedon_commit_comment() - Comment on commiton_gollum() - Wiki page updateon_public() - Repository made publicon_repository() - Repository eventson_repository_dispatch() - Repository dispatchon_repository_import() - Repository importon_branch_protection_rule() - Branch protection rule eventson_workflow_run() - Workflow run eventson_workflow_job() - Workflow job eventson_workflow_dispatch() - Workflow dispatch eventson_status() - Commit status eventson_check_run() - Check run eventson_check_suite() - Check suite eventson_code_scanning_alert() - Code scanning alertson_secret_scanning_alert() - Secret scanning alertson_secret_scanning_alert_location() - Secret scanning alert locationon_dependabot_alert() - Dependabot alertson_repository_vulnerability_alert() - Repository vulnerability alertson_security_advisory() - Security advisory eventson_repository_advisory() - Repository advisory eventson_security_and_analysis() - Security and analysis eventson_deployment() - Deployment eventson_deployment_status() - Deployment status eventson_deploy_key() - Deploy key eventson_deployment_protection_rule() - Deployment protection rule eventson_discussion() - Discussion eventson_discussion_comment() - Discussion comment eventson_project() - Project (classic) eventson_project_card() - Project card eventson_project_column() - Project column eventson_projects_v2() - Projects v2 eventson_projects_v2_item() - Projects v2 item eventson_team() - Team eventson_team_add() - Team add eventson_member() - Member eventson_membership() - Membership eventson_organization() - Organization eventson_org_block() - Org block eventson_release() - Release eventson_package() - Package eventson_registry_package() - Registry package eventson_installation() - Installation eventson_installation_repositories() - Installation repositories eventson_installation_target() - Installation target eventson_github_app_authorization() - GitHub App authorization eventson_personal_access_token_request() - Personal access token request eventson_label() - Label eventson_milestone() - Milestone eventson_watch() - Watch (star) eventson_star() - Star eventson_ping() - Ping eventson_meta() - Meta eventson_page_build() - Page build eventson_schedule() - Schedule eventson_sponsorship() - Sponsorship eventson_marketplace_purchase() - Marketplace purchase eventson_merge_group() - Merge group eventsCheck the examples directory or the example below:
use std::sync::Arc;
use octofer::{Octofer, Config};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config::from_env().unwrap_or_default();
config.init_logging();
let mut app = Octofer::new(config).await.unwrap_or_else(|_| {
Octofer::new_default()
});
// Handle issue comments
app.on_issue_comment(
|context, _| async move {
println!("Issue comment event received!");
println!("Event type: {}", context.kind());
if let Some(client) = &context.github_client {
// Use GitHub API client here
println!("GitHub client available for API calls");
}
Ok(())
},
Arc::new(()),
).await;
app.start().await?;
Ok(())
}
Octofer uses a centralized configuration system that loads from environment variables:
# Required for GitHub App authentication
export GITHUB_APP_ID=your_app_id
export GITHUB_PRIVATE_KEY_PATH=path/to/private-key.pem
# OR
export GITHUB_PRIVATE_KEY_BASE64=base64_encoded_key
# Webhook
export GITHUB_WEBHOOK_SECRET=your_webhook_secret
# Server configuration (optional)
export OCTOFER_HOST=127.0.0.1 # Default: 127.0.0.1
export OCTOFER_PORT=8000 # Default: 8000
# Logging configuration (optional)
export OCTOFER_LOG_LEVEL=info # Default: info (trace, debug, info, warn, error)
export OCTOFER_LOG_FORMAT=compact # Default: compact (compact, pretty, json)
export OCTOFER_LOG_WITH_TARGET=false # Default: false (show target module)
export OCTOFER_LOG_WITH_FILE=false # Default: false (show file and line info)
export OCTOFER_LOG_WITH_THREAD_IDS=false # Default: false (show thread IDs)
You can also create configuration programmatically:
use octofer::Config;
let config = Config::new(
123456, // app_id
Some("path/to/private-key.pem".to_string()), // private_key_path
None, // private_key_base64
"your-webhook-secret".to_string(), // webhook_secret
std::net::Ipv4Addr::LOCALHOST, // host
8000, // port
)?;
// Initialize logging with the configuration
config.init_logging();
Build all components:
cargo build
Run tests:
cargo test
Format code:
cargo fmt
Run linting:
cargo clippy -- -D warnings
Config structEvent handlers receive a Context object that provides access to:
context.payload() - The full GitHub webhook payloadcontext.event() - The full GitHub webhook eventcontext.kind() - The type of event (e.g., "issues", "issue_comment")context.installation_id() - GitHub App installation IDcontext.github() - Authenticated GitHub API clientcontext.installation_client() - Installation-specific authenticated clientThe repository includes several examples:
basic.rs - Simple GitHub App with event handlers.github_client.rs - Direct GitHub API client usageMIT