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: v17View latest version
This webhook automatically clones a git repository and updates the "lifehub" val with its contents whenever accessed via HTTP.
-
Set the environment variable
repoto your GitHub or GitLab repository URL (HTTPS format):repo=https://github.com/username/repository-name # or repo=https://gitlab.com/username/repository-name -
The webhook is automatically triggered when this val receives an HTTP request.
- ✅ GitHub - Full API support
- ✅ GitLab - Full API support
- ❌ SourceHut - Not supported (no public API)
For SourceHut repositories, please mirror them to GitHub or GitLab to use this webhook.
- Repository Parsing: Extracts owner and repository name from the GitHub/GitLab URL
- Content Fetching: Uses the hosting service's API to recursively fetch all files from the repository
- File Processing: Downloads and processes each file, converting them to Val Town format
- Lifehub Update: Generates code for the "lifehub" val containing all repository content
{ "success": true, "message": "Successfully updated lifehub val with X files from owner/repo", "files": ["file1.js", "file2.md", ...] }
{ "error": "Error description", "details": "Detailed error message" }
The generated lifehub val will include:
- 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 names
curl https://your-val-url.web.val.run
# Get file list curl https://lifehub-val-url.web.val.run # Get specific file curl https://lifehub-val-url.web.val.run?file=README_md
- Only processes text files (binary files are skipped)
- File names are sanitized for Val Town compatibility
- Large repositories may take time to process
- Currently logs the generated code (actual Val Town API integration needed)
repo: GitHub or GitLab repository URL in HTTPS format
- Generated vals are set to "unlisted" privacy by default
- No authentication required for webhook trigger (add if needed)
- Repository must be public or accessible via the provided URL
If you see an error about SourceHut repositories not being supported:
- Create a mirror of your SourceHut repository on GitHub or GitLab
- Update the
repoenvironment variable to point to the GitHub/GitLab URL - Trigger the webhook again
- GitHub: 60 requests per hour for unauthenticated requests
- GitLab: 2000 requests per hour for unauthenticated requests
For higher limits, you can add authentication tokens to the API calls.