deploy
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.
Viewing readonly version of main branch: v21View latest version
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.
-
Set the environment variable
repoto 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 -
The webhook is automatically triggered when this val receives an HTTP request.
- ✅ GitHub - Full support
- ✅ GitLab - Full support
- ✅ SourceHut - Full support
- ✅ Bitbucket - Full support
- ✅ Self-hosted Git - Full support
- ✅ Any Git repository accessible via HTTPS - Full support
- Repository Cloning: Uses isomorphic-git to clone the repository in-memory
- File Processing: Processes all text files from the repository
- Content Filtering: Automatically skips binary files and .git directory
- Lifehub Generation: Creates a comprehensive val containing all repository content
{ "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": "Failed to clone repository", "details": "Detailed error message", "repository": "https://github.com/username/repository-name.git" }
The generated lifehub val includes:
- File Access: Get specific files via
?file=filenamequery parameter - File Listing: GET request without parameters returns all files and metadata
- Helper Functions:
getFile(filename): Get content of a specific filelistFiles(): Get array of all file namessearchFiles(pattern): Search files by regex patterngetFilesByExtension(ext): Get files by extension
# 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
# 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
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");
- Universal Git Support: Works with any Git repository accessible via HTTPS
- In-Memory Processing: No local file system required
- 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 clone failures and processing errors
- Only processes text files (binary files are automatically skipped)
- Clones only the default branch with depth=1 for performance
- File names are sanitized for Val Town compatibility
- Repository must be publicly accessible or use authentication (see below)
For private repositories, you can add authentication by modifying the clone call:
await git.clone({
fs: fsImpl,
http,
dir: '/',
url: repoUrl,
singleBranch: true,
depth: 1,
headers: {
'Authorization': `token ${Deno.env.get('GIT_TOKEN')}`
}
});
repo: Git repository URL in HTTPS format (required)GIT_TOKEN: Authentication token for private repositories (optional)
- 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
- 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