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: v110View 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
# Trigger webhook to check for latest changes curl https://your-val-url.web.val.run
# 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$");
- SourceHut Integration: Specifically designed for SourceHut repositories
- RSS Feed Monitoring: Uses SourceHut's RSS feed format
- 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 (
- SourceHut Specific: Designed specifically for SourceHut repositories
- Public Repository: Works with the public SourceHut workshop repository
- Tarball Format: Relies on SourceHut's
.tar.gztarball format - 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
- Network connectivity issues
No environment variables are required - the webhook is hardcoded to monitor the SourceHut workshop repository.
- 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)