GitHub Actions - Monitoring with Smart Repository Detection
Source: Notion | Last edited: 2024-12-30 | ID: 16c2d2dc-3ef...
📋 The LLM Prompt
Section titled “📋 The LLM Prompt”🛠 Assume using under Cursor Composer Agent Yolo Mode
Use automatic terminal command, don't create any new files.
# Directory Navigation Preferences- Always use `git rev-parse --show-toplevel` as the primary method to detect git repositories- Fall back to `find . -name .git -type d` if the primary method fails- Show both repository name and current working directory in command outputs- Suppress error messages in navigation commands using 2>/dev/null- Always verify repository existence before executing git-related commands
For monitoring GitHub Actions workflow status:1. Navigate to your git repository directory2. Run: gh config set git_protocol ssh && REPO=$(git remote get-url origin | grep-o '[^:]*\\/[^.]*' | tail -1) && gh api -X GET /repos/$REPO/actions/runs | jq '.workflow_runs[0] | {status, conclusion}'
Prerequisites:- Must be in a git repository directory- GitHub CLI (gh) must be installed- SSH key must be configured for GitHub🎯 Purpose
Section titled “🎯 Purpose”This LLM prompt transforms how developers monitor GitHub Actions, providing a reliable and maintainable approach that works across any repository, with built-in error handling and clear output formatting.
💡 Key Features
Section titled “💡 Key Features”1. Smart Repository Detection
Section titled “1. Smart Repository Detection”- Primary Method: Uses
git rev-parse --show-toplevel- Fast and reliable for standard git repositories
- Direct access to repository root
- Fallback Method:
find . -name .git -type d- Handles edge cases where primary method fails
- Works in submodules and nested repositories
2. Error Handling
Section titled “2. Error Handling”- Silent failure with
2>/dev/null - Graceful fallback between methods
- Clear output even when commands fail
3. Informative Output
Section titled “3. Informative Output”Repository: my-project | CWD: /Users/developer/projects/my-projectDetected repo: organization/my-project{ "status": "completed", "conclusion": "success"}🛠️ How It Works
Section titled “🛠️ How It Works”Repository Navigation
Section titled “Repository Navigation”cd $(git rev-parse --show-toplevel 2>/dev/null || find . -name .git -type d -exec dirname {} \\; 2>/dev/null | head -n 1)- Handles both simple and complex repository structures
- Automatically finds the repository root
- Suppresses error messages for clean output
GitHub Actions Status Check
Section titled “GitHub Actions Status Check”gh config set git_protocol ssh && \\REPO=$(git remote get-url origin | grep -o '[^:]*\\/[^.]*' | tail -1) && \\gh api -X GET /repos/$REPO/actions/runs | \\jq '.workflow_runs[0] | {status, conclusion}'🎉 Benefits of Using This Prompt
Section titled “🎉 Benefits of Using This Prompt”- Universal Compatibility
- Works with any GitHub repository
- Supports both HTTPS and SSH remote URLs
- Handles various repository structures
- Developer Experience
- Clean, formatted output
- Silent error handling
- Informative repository context
- Maintainability
- Modular command structure
- Clear fallback patterns
- Easy to extend or modify
🔍 Example Scenarios
Section titled “🔍 Example Scenarios”Standard Project
Section titled “Standard Project”Repository: web-app | CWD: /workspace/web-appDetected repo: company/web-app{ "status": "completed", "conclusion": "success"}Nested Project
Section titled “Nested Project”Repository: backend-service | CWD: /projects/platform/backend-serviceDetected repo: company/backend-service{ "status": "completed", "conclusion": "success"}🎓 Best Practices When Using This Prompt
Section titled “🎓 Best Practices When Using This Prompt”- Copy the entire prompt - Each section is crucial for proper functionality
- Keep prerequisites in mind - Ensure all required tools are installed
- Use as-is first - The prompt is designed to work without modifications
- Customize later - Adapt only after understanding the base functionality
- Maintain security focus - The prompt is designed with security in mind
🔐 Security Considerations
Section titled “🔐 Security Considerations”- Uses SSH for secure authentication
- Avoids exposing sensitive repository information
- Handles credentials securely through GitHub CLI
- No hardcoded repository paths or names
- Error messages suppressed to prevent information leakage
⚙️ Prerequisites Checklist
Section titled “⚙️ Prerequisites Checklist”Before using this prompt, ensure you have:
- Active git repository
- GitHub CLI (
gh) installed - SSH key configured for GitHub
-
jqinstalled for JSON parsing