FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
project logo
charmaineGitHub-PR-Automation
Automate GitHub PR workflows!
Public
Like
2
GitHub-PR-Automation
Home
Code
5
README.md
H
github-pr-auto-assign.ts
H
github-pr-inherit-labels.ts
H
github-pr-title-prefix.ts
H
github-slack-pr-approvals.ts
Branches
1
Pull requests
Remixes
3
History
Environment variables
5
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.
Sign up now
Code
/
README.md
Code
/
README.md
Search
5/6/2025
Viewing readonly version of main branch: v37
View latest version
README.md

GitHub PR Automation Suite

This Val Town project includes several tools for automating GitHub pull request workflows:

  1. PR Approval Notifier: Sends notifications to Slack when a PR is approved, with an optional merge button
  2. PR Auto-Assign: Automatically assigns the PR author as an assignee when a PR is opened
  3. PR Title Prefixer: Automatically prefixes PR titles with the linked issue number
  4. PR Label Inheritor: Automatically copies labels from linked issues to the PR

PR Approval Notifier for Slack

This Val sends notifications to Slack when a GitHub pull request is approved, with an optional merge button that appears when all required checks are passing.

Setup Instructions

1. GitHub Setup

  1. Create a GitHub Personal Access Token (PAT):

    • Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens
    • Create a new token with these permissions:
      • Repository access: Select repositories you want to monitor
      • Permissions:
        • Pull requests: Read and Write
        • Contents: Read and Write (for merging)
        • Metadata: Read-only
    • Save the token for the next step
  2. Set up a GitHub Webhook:

    • Go to your repository → Settings → Webhooks → Add webhook
    • Payload URL: The URL of the respective Val
    • Content type: application/json
    • Select "Let me select individual events"
    • Check only "Pull request reviews"
    • Ensure "Active" is checked
    • Click "Add webhook"

2. Slack Setup

  1. Create a Slack App:

    • Go to Slack API Apps → Create New App → From scratch
    • Name your app and select your workspace
    • Click "Create App"
  2. Enable Interactivity:

    • In your Slack app settings, go to "Interactivity & Shortcuts"
    • Toggle "Interactivity" to On
    • Set the Request URL to the URL of the respective val
    • Save Changes
  3. Create an Incoming Webhook:

    • In your Slack app settings, go to "Incoming Webhooks"
    • Toggle "Activate Incoming Webhooks" to On
    • Click "Add New Webhook to Workspace"
    • Select the channel where notifications should be posted
    • Copy the Webhook URL for the next step

3. Val Town Setup

  1. Add Environment Variables:

    • In Val Town, add these environment variables:
      • GITHUB_TOKEN: Your GitHub Personal Access Token
      • SLACK_WEBHOOK_URL: Your Slack Incoming Webhook URL
  2. Get the Val URL:

    • Copy the Val's URL to use in the GitHub webhook and Slack app settings

How It Works

  1. GitHub sends a webhook event when a PR is reviewed
  2. This Val filters for approval events
  3. When an approval is detected, it:
    • Fetches detailed PR information
    • Checks if the PR is mergeable and all required checks are passing
    • Sends a formatted message to Slack
    • Includes a merge button if the PR can be merged
  4. If the merge button is clicked, the Val:
    • Receives the event from Slack
    • Uses the GitHub API to merge the PR
    • Sends a confirmation message back to Slack

Additional PR Automation Vals

1. PR Auto-Assign

The github-pr-auto-assign.ts val automatically assigns the PR author as an assignee when a PR is opened.

Setup:

  • Create a GitHub webhook with the "Pull requests" event
  • Point it to the auto-assign val URL
  • Add GITHUB_TOKEN as an environment variable in Val Town with these permissions:
    • For classic tokens: Include the "repo" scope
    • For fine-grained tokens: Ensure "Pull requests" has "Read and Write" access
    • Token must be created by a user with write access to the repository

Troubleshooting:

  • If you see a "403: Resource not accessible by personal access token" error, your token doesn't have sufficient permissions. Create a new token with the permissions listed above.

2. PR Title Prefixer

The github-pr-title-prefix.ts val automatically prefixes PR titles with the linked issue number (inline, in the description) when a PR is opened or edited.

Setup:

  • Create a GitHub webhook with the "Pull requests" event
  • Point it to the title prefixer val URL
  • Ensure your GitHub token has appropriate permissions

3. PR Label Inheritor

The github-pr-inherit-labels.ts val automatically copies labels from linked issues to the PR when a PR is opened or edited.

Setup:

  • Create a GitHub webhook with the "Pull requests" event
  • Point it to the label inheritor val URL
  • Ensure your GitHub token has appropriate permissions
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.