Add info logging to webhook handler
Makes it easy to see if GitHub is hitting the endpoint, whether the signature check passes, and whether a deploy is triggered. https://claude.ai/code/session_01FKCW3FDjNFj6jve4niMFXH
This commit is contained in:
parent
ee78f3ff0a
commit
8dab4231ea
1 changed files with 4 additions and 0 deletions
|
|
@ -31,6 +31,8 @@ pub async fn github(
|
||||||
.and_then(|v| v.to_str().ok())
|
.and_then(|v| v.to_str().ok())
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
|
tracing::info!("Webhook received for app {}", app_id);
|
||||||
|
|
||||||
if !verify_sig(&app.webhook_secret, &body, sig) {
|
if !verify_sig(&app.webhook_secret, &body, sig) {
|
||||||
tracing::warn!("Bad webhook signature for app {}", app_id);
|
tracing::warn!("Bad webhook signature for app {}", app_id);
|
||||||
return StatusCode::UNAUTHORIZED;
|
return StatusCode::UNAUTHORIZED;
|
||||||
|
|
@ -45,10 +47,12 @@ pub async fn github(
|
||||||
let pushed_ref = payload["ref"].as_str().unwrap_or("");
|
let pushed_ref = payload["ref"].as_str().unwrap_or("");
|
||||||
let expected_ref = format!("refs/heads/{}", app.branch);
|
let expected_ref = format!("refs/heads/{}", app.branch);
|
||||||
if pushed_ref != expected_ref {
|
if pushed_ref != expected_ref {
|
||||||
|
tracing::info!("Webhook for app {}: ignoring push to {} (watching {})", app_id, pushed_ref, expected_ref);
|
||||||
return StatusCode::OK; // different branch — silently ignore
|
return StatusCode::OK; // different branch — silently ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
let sha = payload["after"].as_str().map(String::from);
|
let sha = payload["after"].as_str().map(String::from);
|
||||||
|
tracing::info!("Webhook triggering deploy for app {} sha={:?}", app_id, sha);
|
||||||
|
|
||||||
if let Err(e) = builder::enqueue_deploy(&s, &app_id, "webhook", sha).await {
|
if let Err(e) = builder::enqueue_deploy(&s, &app_id, "webhook", sha).await {
|
||||||
tracing::error!("Enqueue deploy for {}: {}", app_id, e);
|
tracing::error!("Enqueue deploy for {}: {}", app_id, e);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue