📖 docs: enhance gitea-client REFERENCE.md with real-world use cases and examples
This commit is contained in:
@@ -12,6 +12,9 @@ The Gitea-Client skill provides comprehensive API access to Gitea repositories,
|
|||||||
|
|
||||||
**Commands:**
|
**Commands:**
|
||||||
```bash
|
```bash
|
||||||
|
# List available workflows
|
||||||
|
gitea-client list-workflows <owner> <repo>
|
||||||
|
|
||||||
# List recent workflow jobs
|
# List recent workflow jobs
|
||||||
gitea-client list-jobs <owner> <repo> <workflow_id> [limit]
|
gitea-client list-jobs <owner> <repo> <workflow_id> [limit]
|
||||||
|
|
||||||
@@ -26,23 +29,68 @@ gitea-client list-workflow-jobs <owner> <repo> <workflow_run_id>
|
|||||||
|
|
||||||
# Wait for job completion
|
# Wait for job completion
|
||||||
gitea-client wait-job <owner> <repo> <job_id> [timeout]
|
gitea-client wait-job <owner> <repo> <job_id> [timeout]
|
||||||
|
|
||||||
|
# Monitor workflow run until completion (with automatic updates)
|
||||||
|
gitea-client monitor-workflow <owner> <repo> <workflow_run_id> [interval_seconds]
|
||||||
|
|
||||||
|
# Diagnose failed job with automatic error analysis
|
||||||
|
gitea-client diagnose-job <owner> <repo> <job_id>
|
||||||
|
|
||||||
|
# Get summary of recent workflow runs
|
||||||
|
gitea-client recent-workflows <owner> <repo> [limit] [status_filter]
|
||||||
```
|
```
|
||||||
|
|
||||||
**Example Workflow:**
|
**Example Workflow:**
|
||||||
```bash
|
```bash
|
||||||
# 1. Find recent failed jobs
|
# 1. Get summary of recent workflows
|
||||||
gitea-client list-jobs arcodange dance-lessons-coach 5 10
|
gitea-client recent-workflows arcodange dance-lessons-coach 5
|
||||||
|
|
||||||
# 2. Check status of specific job
|
# 2. Monitor a specific workflow run until completion
|
||||||
|
gitea-client monitor-workflow arcodange dance-lessons-coach 415 30
|
||||||
|
|
||||||
|
# 3. Diagnose a failed job automatically
|
||||||
|
gitea-client diagnose-job arcodange dance-lessons-coach 759
|
||||||
|
|
||||||
|
# 4. List available workflows to get workflow IDs
|
||||||
|
gitea-client list-workflows arcodange dance-lessons-coach
|
||||||
|
|
||||||
|
# 5. Check status of specific job
|
||||||
gitea-client job-status arcodange dance-lessons-coach 706
|
gitea-client job-status arcodange dance-lessons-coach 706
|
||||||
|
|
||||||
# 3. Fetch logs for debugging
|
# 6. Fetch logs for debugging
|
||||||
gitea-client job-logs arcodange dance-lessons-coach 706 job_706_logs.txt
|
gitea-client job-logs arcodange dance-lessons-coach 706 job_706_logs.txt
|
||||||
|
|
||||||
# 4. Analyze logs
|
# 7. Analyze logs manually
|
||||||
grep -i "error\|fail" job_706_logs.txt
|
grep -i "error\|fail" job_706_logs.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Advanced Monitoring Example:**
|
||||||
|
```bash
|
||||||
|
# Monitor workflow and automatically diagnose if it fails
|
||||||
|
WORKFLOW_ID=415
|
||||||
|
TIMEOUT=300
|
||||||
|
SECONDS_ELAPSED=0
|
||||||
|
|
||||||
|
while [ $SECONDS_ELAPSED -lt $TIMEOUT ]; do
|
||||||
|
STATUS=$(gitea-client job-status arcodange dance-lessons-coach $WORKFLOW_ID | jq -r '.status')
|
||||||
|
CONCLUSION=$(gitea-client job-status arcodange dance-lessons-coach $WORKFLOW_ID | jq -r '.conclusion')
|
||||||
|
|
||||||
|
echo "[$(date)] Status: $STATUS, Conclusion: ${CONCLUSION:-not completed}"
|
||||||
|
|
||||||
|
if [[ "$CONCLUSION" == "failure" ]]; then
|
||||||
|
echo "Job failed! Running diagnosis..."
|
||||||
|
gitea-client diagnose-job arcodange dance-lessons-coach $WORKFLOW_ID
|
||||||
|
break
|
||||||
|
elif [[ "$STATUS" != "in_progress" && "$STATUS" != "waiting" ]]; then
|
||||||
|
echo "Job completed with status: $STATUS"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 30
|
||||||
|
SECONDS_ELAPSED=$((SECONDS_ELAPSED + 30))
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
### 2. Pull Request Management
|
### 2. Pull Request Management
|
||||||
|
|
||||||
**Scenario:** Monitor and comment on PRs during CI/CD
|
**Scenario:** Monitor and comment on PRs during CI/CD
|
||||||
@@ -405,3 +453,78 @@ curl -s https://gitea.arcodange.lab/swagger.v1.json | \
|
|||||||
- **JQ Tutorial**: https://stedolan.github.io/jq/manual/
|
- **JQ Tutorial**: https://stedolan.github.io/jq/manual/
|
||||||
|
|
||||||
This reference guide provides comprehensive examples for using the gitea-client skill in real-world scenarios, covering job monitoring, PR management, issue tracking, and API discovery with practical, copy-paste-ready examples.
|
This reference guide provides comprehensive examples for using the gitea-client skill in real-world scenarios, covering job monitoring, PR management, issue tracking, and API discovery with practical, copy-paste-ready examples.
|
||||||
|
|
||||||
|
## 🎯 Real-World Use Cases from DanceLessonsCoach
|
||||||
|
|
||||||
|
### CI/CD Pipeline Debugging
|
||||||
|
|
||||||
|
**Scenario**: TLS certificate verification failures were blocking all CI/CD progress.
|
||||||
|
|
||||||
|
**Solution**: Replaced Docker Buildx with traditional docker build + push.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Before (Failed)
|
||||||
|
# ERROR: failed to build: failed to solve: failed to push
|
||||||
|
# tls: failed to verify certificate: x509: certificate signed by unknown authority
|
||||||
|
|
||||||
|
# After (Working)
|
||||||
|
gitea-client diagnose-job arcodange dance-lessons-coach 766
|
||||||
|
# Result: Building cache image: gitea.arcodange.lab/... (no TLS errors)
|
||||||
|
|
||||||
|
# Monitor the fix
|
||||||
|
gitea-client monitor-workflow arcodange dance-lessons-coach 418 30
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automated CI Monitoring
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Monitor workflow and auto-diagnose failures
|
||||||
|
WORKFLOW_ID=418
|
||||||
|
TIMEOUT=300
|
||||||
|
SECONDS_ELAPSED=0
|
||||||
|
|
||||||
|
while [ $SECONDS_ELAPSED -lt $TIMEOUT ]; do
|
||||||
|
STATUS=$(gitea-client job-status arcodange dance-lessons-coach $WORKFLOW_ID | jq -r '.status')
|
||||||
|
CONCLUSION=$(gitea-client job-status arcodange dance-lessons-coach $WORKFLOW_ID | jq -r '.conclusion')
|
||||||
|
|
||||||
|
echo "[$(date)] Status: $STATUS, Conclusion: ${CONCLUSION:-not completed}"
|
||||||
|
|
||||||
|
if [[ "$CONCLUSION" == "failure" ]]; then
|
||||||
|
echo "❌ Workflow failed! Running diagnosis..."
|
||||||
|
gitea-client diagnose-job arcodange dance-lessons-coach $WORKFLOW_ID
|
||||||
|
break
|
||||||
|
elif [[ "$STATUS" != "in_progress" && "$STATUS" != "waiting" ]]; then
|
||||||
|
echo "✅ Workflow completed: $STATUS"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 30
|
||||||
|
SECONDS_ELAPSED=$((SECONDS_ELAPSED + 30))
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
### PR Management Automation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Automated PR triage based on CI results
|
||||||
|
OPEN_PRS=$(gitea-client list-prs arcodange dance-lessons-coach | jq -r '.[] | select(.state == "open") | .number')
|
||||||
|
|
||||||
|
for pr in $OPEN_PRS; do
|
||||||
|
PR_DETAILS=$(gitea-client pr-status arcodange dance-lessons-coach $pr)
|
||||||
|
BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref')
|
||||||
|
|
||||||
|
# Find related workflows
|
||||||
|
WORKFLOWS=$(gitea-client recent-workflows arcodange dance-lessons-coach 5 | grep "$BRANCH" || echo "")
|
||||||
|
|
||||||
|
if [ -n "$WORKFLOWS" ]; then
|
||||||
|
LATEST_WORKFLOW=$(echo "$WORKFLOWS" | head -1 | cut -d':' -f1)
|
||||||
|
CONCLUSION=$(gitea-client job-status arcodange dance-lessons-coach $LATEST_WORKFLOW | jq -r '.conclusion')
|
||||||
|
|
||||||
|
if [ "$CONCLUSION" = "failure" ]; then
|
||||||
|
gitea-client comment-pr arcodange dance-lessons-coach $pr "⚠️ CI Failed - Check workflow $LATEST_WORKFLOW"
|
||||||
|
elif [ "$CONCLUSION" = "success" ]; then
|
||||||
|
gitea-client comment-pr arcodange dance-lessons-coach $pr "✅ CI Passed - Ready for review!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user