GitHubCommunityActions
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.
This Val Town application monitors a GitHub repository for new discussions and sends email notifications when new discussions are created.
- Monitors a GitHub repository for new discussions
- Sends email notifications for new discussions
- Keeps track of which discussions have already been processed
- Can be scheduled to run at regular intervals
-
Set up environment variables:
GITHUB_TOKEN
: A GitHub personal access token with permissions to read discussions in the repository
-
Configure the monitor:
- Open the
github-discussions-monitor.ts
file - Update the
REPO_OWNER
andREPO_NAME
variables with your target repository information - Optionally, set
EMAIL_NOTIFICATIONS
tofalse
if you don't want email notifications
- Open the
-
Set up a cron trigger:
- In the Val Town web UI, set up a cron trigger for this val to run at your desired frequency
- Recommended: Every hour (
0 * * * *
)
- The script fetches the most recent discussions from the specified GitHub repository using the GitHub GraphQL API
- It compares the fetched discussions with a list of previously processed discussions stored in Val Town's blob storage
- For each new discussion, it sends an email notification with details about the discussion
- It updates the list of processed discussions to include the new ones
When run, the function returns a JSON object with the following structure:
{ "status": "success", "newDiscussions": 2, "discussions": [ { "id": "D_kwDOG7...", "title": "New feature request", "url": "https://github.com/owner/repo/discussions/123", "author": "username", "category": "Ideas" }, ... ] }
Or in case of an error:
{ "status": "error", "message": "Error message details" }
- Email Format: You can customize the email format by modifying the
sendNotificationEmail
function - Discussions Query: You can adjust the GraphQL query in
fetchGitHubDiscussions
to change how discussions are fetched - Storage Key: You can change the
STORAGE_KEY
if you want to use a different key for blob storage
- If you're not receiving notifications, check that your GitHub token has the correct permissions
- Ensure the repository has discussions enabled
- Check the Val Town logs for any error messages