This val includes several tools for automating GitHub pull request workflows:
- PR Auto-Assign: Automatically assigns the PR author as an assignee when a PR is opened
- PR Title Prefixer: Automatically prefixes PR titles with the linked issue number
- PR Label Inheritor: Automatically copies labels from linked issues to the PR
- PR Approval Notifier: Sends notifications to Slack when a PR is approved, with an optional merge button
See all 3 in action👇
The github-pr-auto-assign.ts file 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 file URL
- Add
GITHUB_TOKENas 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
The github-pr-title-prefix.ts file 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 file URL
- Ensure your GitHub token has appropriate permissions
The github-pr-inherit-labels.ts file 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 file URL
- Ensure your GitHub token has appropriate permissions
The github-slack-pr-approval.ts file sends notifications to Slack when a GitHub pull request is approved, with an optional merge button that appears when all required checks are passing.
See this in action👇
-
Create a GitHub Personal Access Token (PAT):
- Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens
- If this is not a personal repo, make sure to change the
Resource ownerfrom your personal account to you rorganization. - If you're using GitHub Enterprise, follow these instructions
- 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
-
Set up a GitHub Webhook:
- Go to your repository → Settings → Webhooks → Add webhook
- Payload URL: The URL of the respective file
- Content type:
application/json - Select "Let me select individual events"
- Check only "Pull request reviews"
- Ensure "Active" is checked
- Click "Add webhook"
-
Create a Slack App:
- Go to Slack API Apps → Create New App → From scratch
- Name your app and select your workspace
- Click "Create App"
-
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 file
- Save Changes
-
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
-
Add Environment Variables:
- In Val Town, add these environment variables:
GITHUB_TOKEN: Your GitHub Personal Access TokenSLACK_WEBHOOK_URL: Your Slack Incoming Webhook URL
- In Val Town, add these environment variables:
-
Get the Val URL:
- Copy the file's URL to use in the GitHub webhook and Slack app settings