DevOps / Scripts
bash
Intermediate
GitHub PR Auto-Labeler via CLI
Automatically label GitHub PRs based on changed file paths using the gh CLI.
bash
#!/bin/bash
PR=$1
FILES=$(gh pr diff $PR --name-only)
if echo "$FILES" | grep -q "^frontend/"; then gh pr edit $PR --add-label frontend; fi
if echo "$FILES" | grep -q "^api/"; then gh pr edit $PR --add-label backend; fi
if echo "$FILES" | grep -q "\.tf$"; then gh pr edit $PR --add-label terraform; fi
Prerequisites
- gh CLI
- GitHub repository
Pro Tips
- → Call from a GitHub Actions workflow on pull_request events.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- bash
- Level
- Intermediate
- Read time
- 2 min
- Published
- Jul 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
Postgres S3 Backup
Dump a Postgres database, gzip it, push to S3 with AES256 encryption.
bash
·
Intermediate
Disk Usage Alert
Send an alert when any mounted filesystem exceeds a usage threshold.
bash
·
Beginner
Docker Image Cleanup Script
Remove dangling images, stopped containers and unused volumes in one pass.
bash
·
Intermediate