🚨 ArgoCD Deployment Failed: tech-connect-live #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Trigger Cluster Doctor | |
| # Modified from @sitoader's workflow at: https://github.com/sitoader/AgenticWorkflows/blob/main/.github/workflows/generate-docs.yml | |
| on: | |
| workflow_dispatch: | |
| issues: | |
| types: [labeled] | |
| env: | |
| ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
| ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
| ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
| ARM_USE_OIDC: true | |
| permissions: | |
| id-token: write | |
| contents: read | |
| issues: write | |
| jobs: | |
| run-cluster-doctor: | |
| if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'cluster-doctor' | |
| environment: copilot | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # Required to do OIDC workfload federation token exchange with Azure | |
| contents: write # Required to read repository content and commit diffs | |
| issues: write # Required to create GitHub issues for documentation recommendations | |
| pull-requests: write # Required to create PRs if needed | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitHub Copilot CLI | |
| run: | | |
| curl -fsSL https://gh.io/copilot-install | bash | |
| echo "Installed Copilot CLI version:" | |
| copilot --version | |
| - name: Parse cluster info from issue body | |
| id: cluster-info | |
| env: | |
| GITHUB_MCP_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }} | |
| run: | | |
| echo "Parsing cluster info from issue #${{ github.event.issue.number }}..." | |
| # Set variables for prompt substitution | |
| export ISSUE_NUMBER="${{ github.event.issue.number }}" | |
| export REPOSITORY="${{ github.repository }}" | |
| # Load and substitute variables in prompt | |
| PROMPT=$(envsubst < .github/prompts/parse-cluster-info.md) | |
| # Run Copilot and capture output | |
| COPILOT_OUTPUT=$(copilot -p "$PROMPT" \ | |
| --agent "cluster-doctor" \ | |
| --additional-mcp-config @'.copilot/mcp-config.json' \ | |
| --allow-all-tools 2>&1) | |
| echo "Copilot output:" | |
| echo "$COPILOT_OUTPUT" | |
| # Extract RESOURCE_GROUP and CLUSTER_NAME from Copilot output | |
| RESOURCE_GROUP=$(echo "$COPILOT_OUTPUT" | grep -oP 'RESOURCE_GROUP=\K[^\s]+' | head -1) | |
| CLUSTER_NAME=$(echo "$COPILOT_OUTPUT" | grep -oP 'CLUSTER_NAME=\K[^\s]+' | head -1) | |
| # Check for errors | |
| if echo "$COPILOT_OUTPUT" | grep -q "ERROR="; then | |
| echo "ERROR: Failed to extract cluster info from issue body" | |
| echo "$COPILOT_OUTPUT" | |
| exit 1 | |
| fi | |
| if [ -z "$RESOURCE_GROUP" ] || [ -z "$CLUSTER_NAME" ]; then | |
| echo "ERROR: Could not parse RESOURCE_GROUP or CLUSTER_NAME from Copilot output" | |
| echo "RESOURCE_GROUP='$RESOURCE_GROUP'" | |
| echo "CLUSTER_NAME='$CLUSTER_NAME'" | |
| exit 1 | |
| fi | |
| echo "RESOURCE_GROUP=$RESOURCE_GROUP" >> $GITHUB_OUTPUT | |
| echo "CLUSTER_NAME=$CLUSTER_NAME" >> $GITHUB_OUTPUT | |
| echo "Extracted from issue: RG=$RESOURCE_GROUP, Cluster=$CLUSTER_NAME" | |
| - name: Azure CLI Login | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.ARM_CLIENT_ID }} | |
| tenant-id: ${{ secrets.ARM_TENANT_ID }} | |
| subscription-id: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
| - name: Verify Azure Login | |
| run: | | |
| echo "Verifying Azure authentication..." | |
| az account show | |
| - name: Get AKS Credentials | |
| run: | | |
| echo "Fetching kubeconfig for cluster ${{ steps.cluster-info.outputs.CLUSTER_NAME }}..." | |
| az aks get-credentials \ | |
| --resource-group ${{ steps.cluster-info.outputs.RESOURCE_GROUP }} \ | |
| --name ${{ steps.cluster-info.outputs.CLUSTER_NAME }} \ | |
| --overwrite-existing | |
| echo "Kubeconfig fetched successfully!" | |
| kubectl cluster-info | |
| kubectl port-forward -n aks-mcp svc/aks-mcp 8000:8000 & | |
| sleep 3 # Wait for port-forward to establish | |
| - name: Analyze and delegate to Copilot | |
| env: | |
| GITHUB_MCP_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Workflow token for MCP GitHub operations (issues) | |
| GITHUB_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }} # Personal PAT for Copilot API authentication | |
| run: | | |
| echo "Analyzing issue #${{ github.event.issue.number }}" | |
| echo "Loading documentation criteria from prompt..." | |
| export PROMPT="Use the GitHub MCP Server to help analyze GitHub Issue #${{ github.event.issue.number }} in the repository ${{ github.repository }}. Any changes or fixes should be documented back in the GitHub Issue as a comment in the thread, and use GitHub MCP server to create a PR should any material changes to the repo be made as part of the fix and noted as part of the issue comment response, also via GitHub MCP server. Leverage the AKS MCP server to get additional information to verify the issue and details about the AKS cluster." | |
| echo "Delegating to GitHub Copilot..." | |
| echo "- Copilot will use MCP to examine the issue" | |
| echo "- Copilot will decide if changes are needed" | |
| echo "- Copilot will create an issue comment, PR and link them as needed." | |
| echo "" | |
| copilot -p "$PROMPT" \ | |
| --agent "cluster-doctor" \ | |
| --additional-mcp-config @'.copilot/mcp-config.json' \ | |
| --allow-all-tools |