File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 GITHUB_TOKEN : ${{ secrets.DIRECTORY_GITHUB_TOKEN }}
2929 GITHUB_REPO : ArcedeDev/open-402
3030 CONCURRENCY : ' 15'
31+ SYNC_WEBHOOK_SECRET : ${{ secrets.SYNC_WEBHOOK_SECRET }}
32+ SYNC_WEBHOOK_URL : ${{ secrets.SYNC_WEBHOOK_URL }}
3133 run : npx tsx scripts/crawl.ts
Original file line number Diff line number Diff line change @@ -759,6 +759,40 @@ async function main(): Promise<void> {
759759 log ( "ERROR: Failed to commit snapshot.json." ) ;
760760 process . exit ( 1 ) ;
761761 }
762+
763+ // 10. Notify web app to sync snapshot → Supabase (fire-and-forget)
764+ const webhookSecret = process . env . SYNC_WEBHOOK_SECRET ;
765+ const webhookUrl =
766+ process . env . SYNC_WEBHOOK_URL ||
767+ "https://agentinternetruntime.com/api/directory/sync" ;
768+ if ( webhookSecret ) {
769+ try {
770+ const syncRes = await fetch ( webhookUrl , {
771+ method : "POST" ,
772+ headers : {
773+ Authorization : `Bearer ${ webhookSecret } ` ,
774+ "Content-Type" : "application/json" ,
775+ } ,
776+ body : JSON . stringify ( {
777+ triggered_by : "nightly-crawl" ,
778+ timestamp : new Date ( ) . toISOString ( ) ,
779+ } ) ,
780+ signal : AbortSignal . timeout ( 30_000 ) ,
781+ } ) ;
782+ const syncData = ( await syncRes . json ( ) . catch ( ( ) => ( { } ) ) ) as Record < string , unknown > ;
783+ if ( syncRes . ok ) {
784+ log (
785+ `[sync] OK: ${ syncData . synced ?? 0 } synced, ${ syncData . skipped ?? 0 } skipped, ${ syncData . errors ?? 0 } errors`
786+ ) ;
787+ } else {
788+ log (
789+ `[sync] FAILED (${ syncRes . status } ): ${ syncData . error ?? "unknown error" } `
790+ ) ;
791+ }
792+ } catch ( e ) {
793+ log ( `[sync] Webhook failed (non-fatal): ${ e } ` ) ;
794+ }
795+ }
762796}
763797
764798main ( ) . catch ( ( e ) => {
You can’t perform that action at this time.
0 commit comments