A Go-based tool to analyze merged pull requests and determine their presence across release branches. Available as both a CLI tool for individual use and a Slack bot server for team collaboration.
β¨ Ready to use out of the box - go install gives you a fully functional tool, just configure Google Sheets API access! The tool helps track the deployment status of changes across different release versions.
latest- Production branch (stable releases)master- Development branch (active development)
# Install latest release
go install github.com/shay23bra/pr-bot@latest
# Add Go bin to PATH (if needed)
export PATH=$PATH:~/go/bin
# Set up your API tokens
export PR_BOT_GITHUB_TOKEN="your_github_token_here"
export PR_BOT_GITLAB_TOKEN="your_gitlab_token_here"
export PR_BOT_JIRA_TOKEN="your_jira_token_here"
# Start analyzing PRs right away - no external files needed!
pr-bot -pr https://github.com/openshift/assisted-service/pull/7788
# Check version
pr-bot -version# Set up all required tokens in .env file
cat > .env << EOF
# Required tokens for all functionality
PR_BOT_GITHUB_TOKEN=your_github_token_here
PR_BOT_GITLAB_TOKEN=your_gitlab_token_here
PR_BOT_JIRA_TOKEN=your_jira_token_here
# Required for Slack bot server mode (OAuth bot token)
PR_BOT_SLACK_BOT_TOKEN=xoxb-your-bot-token-here
# Required: Google Sheets for GA data
PR_BOT_GOOGLE_API_KEY=your_google_api_key_here
PR_BOT_GOOGLE_SHEET_ID=your_google_sheet_id_here
EOF
# Start server
pr-bot -server
# Use in Slack (multiple ways)
/pr https://github.com/openshift/assisted-service/pull/7788
@pr-bot pr https://github.com/openshift/assisted-service/pull/7788
# Or send direct message: pr https://github.com/openshift/assisted-service/pull/7788- CLI Tool: Perfect for individual developers and CI/CD pipelines
- Slack Bot Server: Team-friendly slash commands for collaborative analysis
- PR Analysis: Get detailed information about merged pull requests including commit hash and merge date
- Release Branch Tracking: Automatically discover and check all release branches matching patterns
- Version Detection: Extract version numbers from branch names and report which versions contain changes
- JIRA Integration: Analyze all PRs related to a JIRA ticket including backports
- MCE Validation: Verify commits against MCE GitLab snapshots with SHA extraction
- GA Status Tracking: Analyze General Availability status from Google Sheets
- Real-time Data: Live release schedule updates directly from Google Sheets
- Release Schedule Integration: Parse "In Progress" and "ACM MCE Completed" tabs to determine GA dates
- Version Comparison: Compare MCE/GitHub versions to track changes between releases with required component-specific analysis
- Auto-Update Notifications: Automatically checks for newer versions and prompts users to update
- Multi-Repository Support: Works with
assisted-service,assisted-installer,assisted-installer-agent, andassisted-installer-ui - Flexible Configuration: Support for environment variables, config files, and command-line options
- High Performance: Optimized with caching and parallel processing to minimize API calls
This tool uses Google Sheets API as the exclusive data source for GA (General Availability) release information:
- β Real-time Data: Always uses the latest release schedule from Google Sheets
- π Live Updates: Changes reflect immediately without redeployment
- π Secure Access: API key authentication with configurable restrictions
- π± Easy Maintenance: Familiar spreadsheet interface for data management
- π No Rebuilds: Update GA data through Google Sheets without touching code
Both environment variables are required for the tool to function:
export PR_BOT_GOOGLE_API_KEY="your-google-api-key"
export PR_BOT_GOOGLE_SHEET_ID="your-google-sheet-id"- β Real-time Updates: Live data from Google Sheets
- β Zero Downtime: Update data without restarting services
- β Collaborative: Multiple users can maintain the release schedule
- β Audit Trail: Google Sheets provides change history
- β Simplified Deployment: No data files to manage
pr-bot --config
# Shows your current configuration including Google Sheets setup# Install latest stable release (recommended)
go install github.com/shay23bra/[email protected]
# Or install from production branch
go install github.com/shay23bra/pr-bot@latest
# Add Go bin directory to PATH (if not already done)
echo 'export PATH=$PATH:~/go/bin' >> ~/.bashrc
source ~/.bashrc
# Verify installation
pr-bot -version# Download from GitHub releases (replace VERSION with actual version)
wget https://github.com/shay23bra/pr-bot/releases/latest/download/pr-bot-linux-amd64
chmod +x pr-bot-linux-amd64
mv pr-bot-linux-amd64 pr-bot
# Add to PATH
sudo mv pr-bot /usr/local/bin/# Clone repository
git clone https://github.com/shay23bra/pr-bot.git
cd pr-bot
# Build the application
go build .
# Configure Google Sheets access (required)
export PR_BOT_GOOGLE_API_KEY="your-google-api-key"
export PR_BOT_GOOGLE_SHEET_ID="your-google-sheet-id"
# Verify configuration
./pr-bot --configFor project maintainers who can build and release new versions:
- Google Sheets API access (API key and Sheet ID)
- GitHub repository write access
- Being listed in the GitHub Actions workflow conditions
# Clone repository
git clone https://github.com/shay23bra/pr-bot.git
cd pr-bot
# Build CLI distribution version
./scripts/build-cli.sh
# For releases, build and release:
./scripts/build-cli.sh
gh release create v0.X.X --title "vX.X.X - Release Title" --notes "Release notes" ./pr-botβ‘ New Architecture Benefits:
- No sensitive data files in the repository
- Real-time data updates without rebuilding
- Simplified build process for all contributors
- Users configure their own Google Sheets access
- Go 1.21 or later (if building from source)
- GitHub token (REQUIRED) - For API access
- GitLab token (REQUIRED) - For MCE validation
- JIRA token (REQUIRED) - For JIRA ticket analysis
- Red Hat VPN connection (REQUIRED) - For accessing internal GitLab and JIRA APIs
- Google Sheets API access (REQUIRED) - For GA release schedule data
- Go to GitHub Settings > Personal Access Tokens
- Click "Generate new token (classic)"
- Give it a name like "pr-bot"
- Select scopes:
public_repo(for public repos) orrepo(for private repos) - Copy the generated token
- Set it as an environment variable:
- For CLI usage:
export PR_BOT_GITHUB_TOKEN="your_token_here"
- For Slack server usage (add to .env file):
echo "PR_BOT_GITHUB_TOKEN=your_token_here" >> .env
For JIRA ticket analysis, you'll need a JIRA API token:
-
Get JIRA API Token:
- Go to Red Hat JIRA API Tokens
- Click "Create token"
- Give it a name like "pr-bot"
- Copy the generated token
-
Set as environment variable:
- For CLI usage:
export PR_BOT_JIRA_TOKEN="your-jira-token-here"
- For Slack server usage (add to .env file):
echo "PR_BOT_JIRA_TOKEN=your-jira-token-here" >> .env
- For CLI usage:
Important Notes:
- Required only if you want to use the
-jtflag for JIRA ticket analysis - The token should have read access to JIRA issues
- Used to find cloned tickets and extract GitHub PR URLs from JIRA tickets
For MCE snapshot validation (used in PR analysis and version comparison), you'll need a GitLab API token:
-
Get GitLab API Token:
- Go to GitLab Personal Access Tokens
- Click "Add new token"
- Give it a name like "pr-bot"
- Select scope:
read_api(for reading repository files) - Set expiration date (optional)
- Copy the generated token
-
Set as environment variable:
- For CLI usage:
export PR_BOT_GITLAB_TOKEN="your-gitlab-token-here"
- For Slack server usage (add to .env file):
echo "PR_BOT_GITLAB_TOKEN=your-gitlab-token-here" >> .env
- For CLI usage:
Important Notes:
- Required for MCE snapshot validation (SHA extraction from down-sha.yaml)
- Used in PR analysis to validate against MCE snapshots
- Enables version comparison features (
-vflag) - Token should have
read_apiscope to access MCE repository files
The tool requires Google Sheets API access for GA release schedule data:
-
Get Google API Key:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the "Google Sheets API"
- Go to "Credentials" β "Create Credentials" β "API Key"
- Copy the generated API key
- (Optional) Restrict the key to "Google Sheets API" for security
-
Get Google Sheet ID:
- Open your Google Sheet (e.g., ACM/MCE release schedule)
- Copy the Sheet ID from the URL:
https://docs.google.com/spreadsheets/d/SHEET_ID_HERE/edit - Make sure the sheet is accessible with the API key (either public or shared)
-
Set as environment variables:
- For CLI usage:
export PR_BOT_GOOGLE_API_KEY="your-google-api-key" export PR_BOT_GOOGLE_SHEET_ID="your-google-sheet-id"
- For Slack server usage (add to .env file):
echo "PR_BOT_GOOGLE_API_KEY=your-google-api-key" >> .env echo "PR_BOT_GOOGLE_SHEET_ID=your-google-sheet-id" >> .env
- For CLI usage:
Important Notes:
- Recommended: Provides real-time data without rebuilding binaries
- Sheet Structure: Must have "In Progress" and "Completed Releases" tabs
- Required: Both API key and Sheet ID must be configured for the tool to work
- Security: Keep your API key secure and consider IP restrictions
- Access: Sheet must be accessible with your API key (public or shared)
git clone https://github.com/shay23bra/pr-bot.git
cd pr-bot
go mod tidyYou can configure the application using a .env file in the project root:
# Copy the example file
cp env.example .env
# Edit the .env file with your tokens
nano .envThe .env file should contain:
# GitHub Configuration
PR_BOT_GITHUB_TOKEN=your-github-token-here
PR_BOT_GITHUB_OWNER=openshift
PR_BOT_GITHUB_REPOSITORY=assisted-service
PR_BOT_GITHUB_BRANCH_PREFIX=release-ocm-
PR_BOT_GITHUB_DEFAULT_BRANCH=master
# Slack Configuration
PR_BOT_SLACK_XOXD=xoxd-your-browser-token-here
PR_BOT_SLACK_XOXC=xoxc-your-browser-token-here
PR_BOT_SLACK_CHANNEL=team-acm-downstream-notifcation
# GitLab Configuration (for MCE snapshot validation)
PR_BOT_GITLAB_TOKEN=your-gitlab-token-here
# JIRA Configuration (for MGMT ticket analysis)
PR_BOT_JIRA_TOKEN=your-jira-token-heremake buildThe tool can be configured through environment variables, config files, or command-line flags.
# GitHub Configuration (Required)
export PR_BOT_GITHUB_TOKEN="your-github-token"
export PR_BOT_GITHUB_OWNER="openshift"
export PR_BOT_GITHUB_REPOSITORY="assisted-service"
export PR_BOT_GITHUB_BRANCH_PREFIX="release-ocm-"
export PR_BOT_GITHUB_DEFAULT_BRANCH="master"
# Slack Bot Configuration (Required for Slack mode)
export PR_BOT_SLACK_BOT_TOKEN="xoxb-your-bot-token-here"
# Google Sheets Configuration (Required for GA data)
export PR_BOT_GOOGLE_API_KEY="your-google-api-key"
export PR_BOT_GOOGLE_SHEET_ID="your-google-sheet-id"
# GitLab Configuration (Optional for MCE validation)
export PR_BOT_GITLAB_TOKEN="your-gitlab-token-here"
# JIRA Configuration (Required for JIRA ticket analysis)
export PR_BOT_JIRA_TOKEN="your-jira-token-here"Create a config.yaml file:
github:
token: "your-github-token"
owner: "openshift"
repository: "assisted-service"
branch_prefix: "release-ocm-"
default_branch: "master"
slack:
xoxd: "xoxd-your-browser-token-here"
xoxc: "xoxc-your-browser-token-here"
channel: "team-acm-downstream-notifcation"
gitlab:
token: "your-gitlab-token-here"
jira:
token: "your-jira-token-here"- Repository:
openshift/assisted-service - Branch Prefix:
release-ocm- - Default Branch:
master
The CLI tool automatically checks for updates on startup and provides comprehensive PR analysis.
# Show version and check for updates
pr-bot -version
# Show help
pr-bot
# Enable debug logging for any command
pr-bot -d -pr <PR_URL>Analyze merged PRs from any supported repository:
# Analyze a PR (auto-detects repository)
pr-bot -pr https://github.com/openshift/assisted-service/pull/1234
pr-bot -pr https://github.com/openshift/assisted-installer/pull/100
pr-bot -pr https://github.com/openshift/assisted-installer-agent/pull/200
pr-bot -pr https://github.com/openshift-assisted/assisted-installer-ui/pull/2991
# Just use the PR number if you're in the right repo context
pr-bot -pr 1234Analyze all PRs related to a JIRA ticket (finds backports automatically):
# Full URL
pr-bot -jt https://issues.redhat.com/browse/MGMT-20662
# Just ticket ID
pr-bot -jt MGMT-20662# Compare GitHub tag with previous version for specific components
pr-bot -v assisted-service v2.40.1
pr-bot -v assisted-installer v2.44.0
# Compare MCE versions for specific components
pr-bot -v mce assisted-service 2.8.0
pr-bot -v mce assisted-installer 2.8.0Component Selection: For both regular and MCE version comparisons, you must specify which component/repository to analyze:
Available Components:
assisted-service-openshift/assisted-serviceassisted-installer-openshift/assisted-installerassisted-installer-agent-openshift/assisted-installer-agentassisted-installer-ui-openshift-assisted/assisted-installer-ui
Regular Version Comparison: Compares GitHub tags between different releases of the same repository. MCE Version Comparison: Compares component SHAs between MCE snapshots, allowing you to track changes specific to that component between MCE versions.
Note: Component specification is required - there are no defaults to avoid confusion about which repository is being analyzed.
Start the server to enable Slack slash commands:
# Start server (default port 8080)
pr-bot -serverOnce the server is running, use these slash commands in Slack:
# Show help
/info
# Analyze a PR
/pr https://github.com/openshift/assisted-service/pull/1234
# Analyze JIRA ticket
/jt MGMT-20662
# Compare versions (component required)
/version assisted-service v2.40.1
/version assisted-installer v2.44.0
/version mce assisted-service 2.8.0
/version mce assisted-installer 2.8.0Quick Setup:
- Create Slack App: Go to Slack Apps and create a new app
- Add Bot Scopes:
app_mentions:read,channels:read,chat:write,im:read,im:write,commands - Install App: Install to your workspace and copy the Bot User OAuth Token
- Configure Events: Set event URL to
https://your-server.com/slack/events - Add Slash Commands: Create
/info,/pr,/jt,/versionβhttps://your-server.com/slack/commands - Set Token:
PR_BOT_SLACK_BOT_TOKEN=xoxb-your-token
π Detailed Setup Guide: See docs/SLACK_BOT_SETUP.md for complete instructions.
openshift/assisted-serviceopenshift/assisted-installeropenshift/assisted-installer-agentopenshift-assisted/assisted-installer-ui
- assisted-service: Direct SHA extraction from
down-sha.yaml - assisted-installer: Direct SHA extraction from
down-sha.yaml - assisted-installer-agent: Direct SHA extraction from
down-sha.yaml - assisted-installer-ui: Multi-step version extraction via
stolostron/consoleβfrontend/package.jsonβ@openshift-assisted/ui-lib
The tool automatically checks for updates when running CLI commands:
# Example output when a new version is available
$ pr-bot -pr https://github.com/openshift/assisted-service/pull/1234
β οΈ A newer version is available: 0.1.0 (current: 0.0.1)
π¦ Update with: go install github.com/shay23bra/pr-bot@latest
π Or download from: https://github.com/shay23bra/pr-bot/releases/latest
# Then it continues with normal execution...The update check:
- β Non-blocking: Never fails your command if update check fails
- β Fast: 5-second timeout, won't slow you down
- β Informative: Shows current vs latest version and how to update
- β Automatic: No configuration needed
This happens when ~/go/bin is not in your PATH. The binary is installed correctly but your shell can't find it.
Fix:
# Temporary fix (for current session)
export PATH=$PATH:~/go/bin
# Permanent fix (add to your shell profile)
echo 'export PATH=$PATH:~/go/bin' >> ~/.bashrc
source ~/.bashrc
# Verify it works
pr-bot -versionThe CLI validates that required tokens are exported before running commands that need them:
β Missing required environment variables for CLI mode:
β’ PR_BOT_GITHUB_TOKEN
β’ PR_BOT_GITLAB_TOKEN
β’ PR_BOT_JIRA_TOKEN
π§ To fix this, export the missing variables:
export PR_BOT_GITHUB_TOKEN="your_github_token_here"
export PR_BOT_GITLAB_TOKEN="your_gitlab_token_here"
export PR_BOT_JIRA_TOKEN="your_jira_token_here"Note: Help (pr-bot) and version (pr-bot -version) commands don't require tokens.
This was fixed in v0.0.3. If you see this error, clean your module cache:
# Clear module cache and reinstall
go clean -modcache
go install github.com/shay23bra/pr-bot@latestIf you see 403 API rate limit exceeded:
# Make sure you have a GitHub token set
export PR_BOT_GITHUB_TOKEN="your_github_token_here"
# Without a token, you're limited to 60 requests/hour
# With a token, you get 5000 requests/hourIf your IDE shows errors like "No packages found for embedded files" or import issues:
Issue: The embedded package uses build tags, which can confuse IDEs.
For VSCode with Go extension:
// Add to .vscode/settings.json in your project
{
"go.buildTags": "",
"gopls": {
"buildFlags": ["-tags="]
}
}For other editors:
- Default build (no tags) = embedded data version β
- Use
-tags=filesystemfor development with external files - Build tag warnings are normal - both versions build correctly
Verify both work:
go build . # filesystem version (default)
go build -tags=embedded . # embedded version (maintainers only)- Create installation script for your team:
#!/bin/bash
# install-pr-bot.sh
echo "π Installing pr-bot..."
# Install latest version
go install github.com/shay23bra/pr-bot@latest
# Verify installation
pr-bot -version
echo "β
Installation complete!"
echo "π Next steps:"
echo "1. Set up your tokens via export:"
echo " export PR_BOT_GITHUB_TOKEN='your_github_token_here'"
echo " export PR_BOT_GITLAB_TOKEN='your_gitlab_token_here'"
echo " export PR_BOT_JIRA_TOKEN='your_jira_token_here'"
echo "2. Test with: pr-bot -pr <PR_URL>"- Docker deployment (recommended):
# Dockerfile
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o pr-bot .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/pr-bot .
COPY --from=builder /app/VERSION .
COPY --from=builder /app/data ./data
EXPOSE 8080
CMD ["./pr-bot", "-server"]- Kubernetes deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: pr-bot
spec:
replicas: 2
selector:
matchLabels:
app: pr-bot
template:
metadata:
labels:
app: pr-bot
spec:
containers:
- name: pr-bot
image: your-registry/pr-bot:latest
ports:
- containerPort: 8080
env:
- name: PR_BOT_GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: pr-bot-secrets
key: github-token
# ... other environment variables./pr-bot -d -pr https://github.com/openshift/assisted-service/pull/1234Debug mode provides detailed logging including:
- Configuration values at startup
- Google Sheets API parsing progress
- GA status analysis steps
- GitHub API request details
- Release branch matching logic
./pr-botgo run main.go -slackgo run main.go -slack -slack-limit 200go run main.go -version 2.13This finds the latest message in the Slack channel that contains the specified version and includes an "Upstream SHA list" link.
=== PR Analysis Summary ===
PR #1234: Fix authentication bug in installer
Hash: a1b2c3d4e5f6
Merged to 'master' at: 2024-01-15 10:30:00 +0000 UTC
URL: https://github.com/openshift/assisted-service/pull/1234
=== Release Branch Analysis ===
β Found in 3 release branches:
- release-ocm-2.13 (version 2.13) - merged at 2024-01-16 14:20:00 +0000 UTC
GA Status:
ACM 2.13.3: GA (GA: 2024-01-10)
MCE 2.8.2: GA (GA: 2024-01-10)
- release-ocm-2.14 (version 2.14) - merged at 2024-01-17 09:15:00 +0000 UTC
GA Status:
ACM 2.14.1: Next Version (GA: 2024-02-15)
MCE 2.9.1: Merged but not GA
- release-ocm-2.15 (version 2.15) - merged at 2024-01-18 11:45:00 +0000 UTC
GA Status:
ACM 2.15.0: Not Found
MCE 2.10.0: Not Found
β Not found in 2 release branches:
- release-ocm-2.10 (version 2.10)
- release-ocm-2.11 (version 2.11)
Analysis completed at: 2024-01-20 16:30:00 +0000 UTC
=== Slack Search Results ===
Channel: team-acm-downstream-notifcation
Messages searched: 100
PR-related messages found: 3
PR References Found:
PR #1234 - 2024-01-15 14:30:00
Message: Merged PR #1234 to release-ocm-2.13
User: U1234567890
PR #1235 - 2024-01-16 09:15:00
Message: Backported PR #1235 to release-ocm-2.14
User: U0987654321
PR #1236 - 2024-01-17 11:45:00
Message: PR #1236 is ready for review
User: U1122334455
=== Version Search Results ===
Target Version: 2.13
Channel: team-acm-downstream-notifcation
Messages searched: 100
Latest message found:
Timestamp: 2024-01-15 14:30:00
User: U1234567890
Upstream SHA List: https://github.com/openshift/assisted-service/compare/upstream-2.13...release-ocm-2.13
Message: ACM 2.13.3 is ready for release. Upstream SHA list: https://github.com/openshift/assisted-service/compare/upstream-2.13...release-ocm-2.13
- GA: The change is included in a Generally Available release
- Next Version: The change was merged after the GA date, so it will be in the next version
- Merged but not GA: The change is merged but no GA date is available yet
- Not Found: No release information found for this version
All changes require maintainer approval before merging.
- π Open issues for discussions and feature requests
- π Submit PRs for code changes - all PRs require review
- β³ Wait for approval - no self-merging allowed
- π« No direct pushes - all changes go through PR process
Contact the repository maintainer for questions or urgent changes.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a PR with clear description
- Wait for maintainer approval
pr-bot/
βββ main.go # Main application entry point
βββ internal/
β βββ config/ # Configuration management
β βββ github/ # GitHub API client
β βββ ga/ # GA status parsing
β βββ logger/ # Logging utilities
β βββ models/ # Data models
β βββ slack/ # Slack API client
βββ pkg/
β βββ analyzer/ # Core analysis logic
βββ scripts/ # Build and utility scripts
βββ go.mod # Go module definition
βββ Makefile # Build automation
βββ README.md # This file
# Show available commands
make help
# Build the application
make build
# Run tests
make test
# Format code
make fmt
# Run linter
make lint
# Run all checks
make check
# Clean build artifacts
make cleanThe project follows Go best practices with a clean architecture:
- Models (
internal/models/): Define data structures - GitHub Client (
internal/github/): API interaction layer - Analyzer (
pkg/analyzer/): Business logic - Configuration (
internal/config/): Configuration management - CLI (
main.go): Command-line interface - GA Parser (
internal/ga/): Google Sheets parsing for release tracking
- Without GitHub token: 60 requests per hour
- With GitHub token: 5,000 requests per hour
For production use, always configure a GitHub token.
If you have issues with the Slack bot:
- Check bot token: Ensure
PR_BOT_SLACK_BOT_TOKENis set correctly - Verify scopes: Make sure all required bot scopes are configured
- Check installation: Ensure the app is installed to your workspace
- Test endpoints: Verify your server is accessible at the configured URLs
- Use debug mode: Run with
-dflag to see detailed error messages:./pr-bot -server -d
See docs/SLACK_BOT_SETUP.md for detailed troubleshooting.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run
make checkto ensure quality - Submit a pull request
This project is licensed under the MIT License.
- JSON output format
- Support for multiple repository analysis
- Batch PR analysis
- Web interface
- Database persistence
- Notification integration (Slack, email)
- CI/CD pipeline integration