• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
flymaster

flymaster

deploy

Public
Like
deploy
Home
Code
2
README.md
H
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
2
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of main branch: v26
View latest version
README.md

Universal Git Repository Webhook

This webhook automatically clones any git repository and updates the "lifehub" val with its contents whenever accessed via HTTP. Uses isomorphic-git for pure JavaScript git operations.

Setup

  1. Set the environment variable repo to any Git repository URL (HTTPS format):

    repo=https://github.com/username/repository-name
    repo=https://gitlab.com/username/repository-name  
    repo=https://git.sr.ht/~username/repository-name
    repo=https://your-git-server.com/username/repository-name
    
  2. The webhook is automatically triggered when this val receives an HTTP request.

Supported Git Hosting Services

  • ✅ GitHub - Full API support (all files, recursive directories)
  • ✅ GitLab - Full API support (all files, recursive directories)
  • ⚠️ SourceHut - Limited support (common files only, no API)
  • ⚠️ Self-hosted Git - Limited support (common files only)
  • ⚠️ Other Git hosts - Limited support (common files only)

Support Levels

Full Support: Uses official APIs to recursively fetch all files from the repository.

Limited Support: Attempts to fetch common files (README, LICENSE, package.json, etc.) using standard URL patterns. May not capture all repository content.

How it works

  1. Repository Parsing: Automatically detects the Git hosting service from the URL
  2. Content Fetching:
    • GitHub/GitLab: Uses official APIs for complete repository access
    • SourceHut/Others: Attempts to fetch common files using standard URL patterns
  3. File Processing: Processes all successfully fetched text files
  4. Content Filtering: Automatically skips binary files and .git directory
  5. Lifehub Generation: Creates a comprehensive val containing all repository content

API Response

Success Response

{ "success": true, "message": "Successfully updated lifehub val with X files from repository-name", "files": ["file1.js", "file2.md", ...], "repository": "https://github.com/username/repository-name.git" }

Error Response

{ "error": "Failed to clone repository", "details": "Detailed error message", "repository": "https://github.com/username/repository-name.git" }

Lifehub Val Features

The generated lifehub val includes:

  • File Access: Get specific files via ?file=filename query parameter
  • File Listing: GET request without parameters returns all files and metadata
  • Helper Functions:
    • getFile(filename): Get content of a specific file
    • listFiles(): Get array of all file names
    • searchFiles(pattern): Search files by regex pattern
    • getFilesByExtension(ext): Get files by extension

Usage Examples

Trigger the webhook

# Regular webhook (uses 'repo' environment variable) curl https://your-val-url.web.val.run # Test with sample repository curl https://your-val-url.web.val.run/test

Access lifehub content

# Get file list and metadata curl https://lifehub-val-url.web.val.run # Get specific file curl https://lifehub-val-url.web.val.run?file=README_md

Use lifehub programmatically

import { getFile, listFiles, searchFiles, getFilesByExtension } from "./lifehub"; // Get a specific file const readme = getFile("README.md"); // List all files const allFiles = listFiles(); // Search for files const jsFiles = searchFiles("\\.js$"); // Get files by extension const markdownFiles = getFilesByExtension("md");

Features

  • Universal Git Support: Works with any Git repository accessible via HTTPS
  • Smart Service Detection: Automatically detects GitHub, GitLab, SourceHut, and generic Git hosts
  • API-First Approach: Uses official APIs when available for complete repository access
  • Fallback Strategy: Attempts to fetch common files when APIs aren't available
  • Binary File Filtering: Automatically skips binary files
  • Text File Processing: Processes all text-based files
  • Comprehensive API: Rich set of helper functions for accessing content
  • Error Handling: Graceful handling of different repository types and access issues

Limitations

  • SourceHut/Generic Git: Limited to common files due to lack of public APIs
  • Private Repositories: Requires authentication (see Authentication section)
  • Binary Files: Automatically skipped for security and performance
  • Large Repositories: GitHub/GitLab APIs may have rate limits
  • File Names: Sanitized for Val Town compatibility

Authentication

For private repositories, you can add authentication by setting environment variables:

GitHub

# Set in Val Town environment GITHUB_TOKEN=your_github_personal_access_token

GitLab

# Set in Val Town environment GITLAB_TOKEN=your_gitlab_access_token

The webhook will automatically use these tokens when accessing private repositories.

Environment Variables

  • repo: Git repository URL in HTTPS format (required)
  • GIT_TOKEN: Authentication token for private repositories (optional)

Security Notes

  • Generated vals are set to "unlisted" privacy by default
  • No authentication required for webhook trigger (add if needed)
  • Repository must be accessible via the provided URL
  • Binary files are automatically filtered out for security

Performance

  • Uses shallow clone (depth=1) for faster processing
  • In-memory file system for efficient processing
  • Processes only text files to reduce memory usage
  • Suitable for repositories up to several hundred files
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.