Skip to content

GitHub Actions - Monitoring with Smart Repository Detection

Source: Notion | Last edited: 2024-12-30 | ID: 16c2d2dc-3ef...


🛠 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 directory
2. 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

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.

  • 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
  • Silent failure with 2>/dev/null
  • Graceful fallback between methods
  • Clear output even when commands fail
Terminal window
Repository: my-project | CWD: /Users/developer/projects/my-project
Detected repo: organization/my-project
{
"status": "completed",
"conclusion": "success"
}
Terminal window
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
Terminal window
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}'
  1. Universal Compatibility
  • Works with any GitHub repository
  • Supports both HTTPS and SSH remote URLs
  • Handles various repository structures
  1. Developer Experience
  • Clean, formatted output
  • Silent error handling
  • Informative repository context
  1. Maintainability
  • Modular command structure
  • Clear fallback patterns
  • Easy to extend or modify
Terminal window
Repository: web-app | CWD: /workspace/web-app
Detected repo: company/web-app
{
"status": "completed",
"conclusion": "success"
}
Terminal window
Repository: backend-service | CWD: /projects/platform/backend-service
Detected repo: company/backend-service
{
"status": "completed",
"conclusion": "success"
}

🎓 Best Practices When Using This Prompt

Section titled “🎓 Best Practices When Using This Prompt”
  1. Copy the entire prompt - Each section is crucial for proper functionality
  2. Keep prerequisites in mind - Ensure all required tools are installed
  3. Use as-is first - The prompt is designed to work without modifications
  4. Customize later - Adapt only after understanding the base functionality
  5. Maintain security focus - The prompt is designed with security in mind
  1. Uses SSH for secure authentication
  2. Avoids exposing sensitive repository information
  3. Handles credentials securely through GitHub CLI
  4. No hardcoded repository paths or names
  5. Error messages suppressed to prevent information leakage

Before using this prompt, ensure you have:

  • Active git repository
  • GitHub CLI (gh) installed
  • SSH key configured for GitHub
  • jq installed for JSON parsing