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: v44View latest version
This webhook monitors the SourceHut workshop repository at https://git.sr.ht/~fly/workshop by fetching its RSS feed and deploying the latest changes to a lifehub val.
- RSS Feed: Fetches the repository's RSS feed from
https://git.sr.ht/~fly/workshop/log/rss.xml - Latest Commit: Gets the most recent commit from the RSS feed
- Tarball Download: Downloads the tarball from SourceHut's archive endpoint
- File Extraction: Extracts all non-dot files from the tarball
- Lifehub Deployment: Creates/updates the lifehub val with all repository content
The webhook is automatically configured to monitor:
- Repository: https://git.sr.ht/~fly/workshop
- RSS Feed: https://git.sr.ht/~fly/workshop/log/rss.xml
No environment variables are required - the webhook is hardcoded to monitor this specific repository.
The webhook is automatically triggered when this val receives an HTTP request.
{ "success": true, "message": "Successfully deployed X files to lifehub val", "files": ["file1.js", "file2.md", ...], "repository": "https://git.sr.ht/~fly/workshop", "commit": "Latest commit message", "commitLink": "https://git.sr.ht/~fly/workshop/commit/abc123" }
{ "error": "Failed to process repository", "details": "Detailed error message", "repository": "https://git.sr.ht/~fly/workshop" }
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
- Repository Metadata: Commit info, timestamps, and repository details
- Helper Functions:
getFile(filename): Get content of a specific filelistFiles(): Get array of all file namesgetMetadata(): Get repository and commit metadatasearchFiles(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, getMetadata, searchFiles } from "./lifehub";
// Get a specific file
const readme = getFile("README.md");
// List all files
const allFiles = listFiles();
// Get repository metadata
const meta = getMetadata();
console.log(`Last commit: ${meta.lastCommit}`);
// Search for files
const jsFiles = searchFiles("\\.js$");
- Universal Compatibility: Works with any Git host that provides RSS feeds
- Latest Commit Tracking: Always gets the most recent changes
- Complete Repository: Downloads entire repository content via tarball
- Non-Dot File Filtering: Automatically excludes hidden files and .git directory
- Binary File Filtering: Automatically skips binary files
- Rich Metadata: Includes commit information and timestamps
- Comprehensive API: Full set of helper functions for accessing content
- Included: All text files that don't start with a dot
- Excluded:
- Dot files (
.gitignore,.env, etc.) .gitdirectory and contents- Binary files (detected by null bytes)
- Directory entries
- Dot files (
- RSS Dependency: Requires the Git hosting service to provide RSS feeds
- Public Repositories: Works best with public repositories (private repos may need authentication)
- Tarball Format: Relies on standard
.tar.gztarball availability - Text Files Only: Binary files are automatically filtered out
- File Names: Sanitized for Val Town compatibility
The webhook provides detailed error messages for common issues:
- RSS feed not found or inaccessible
- No commits found in RSS feed
- Tarball download failures
- Extraction errors
- Invalid repository URLs
repo: Git repository URL in HTTPS format (required)
- Generated vals are set to "unlisted" privacy by default
- No authentication required for webhook trigger
- Repository must be publicly accessible or provide public RSS feeds
- Binary files are automatically filtered out for security
- Only non-dot files are included to avoid sensitive configuration files
- Efficient: Downloads only the latest commit via tarball
- Complete: Gets entire repository content in one request
- Fast: No recursive API calls needed
- Memory Efficient: Processes files individually during extraction
- Scalable: Works with repositories of any size (within memory limits)