Gemini-LLM GCS Artifact Test #22
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: Gemini-LLM GCS Artifact Test | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| use_prod_service_url: | |
| description: "Call the Cloud Run service after downloading artifacts" | |
| required: false | |
| type: boolean | |
| default: false | |
| prompt_file: | |
| description: "Select a prompt to use for analysis" | |
| required: true | |
| default: "multi-analyze.txt" | |
| type: choice | |
| options: | |
| - multi-analyze.txt | |
| permissions: | |
| contents: read | |
| env: | |
| GCP_PROJECT_ID: moz-testops-tools | |
| SERVICE_URL: https://llm-tool-620861480696.us-central1.run.app | |
| CRASH_URI: gs://testops-llm-artifacts/crashes/minidumps/examples/crash_example.txt | |
| ANR_URI: gs://testops-llm-artifacts/anr/examples/anr_example.txt | |
| IMG_URI: gs://testops-llm-artifacts/images/examples/iOS/1.png | |
| LOCAL_ARTIFACT_DIR: artifacts | |
| jobs: | |
| manual-run: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Authenticate to Google Cloud (JSON key) | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_VERTEX_AI }} | |
| - name: Setup gcloud | |
| uses: google-github-actions/setup-gcloud@v3 | |
| with: | |
| project_id: ${{ env.GCP_PROJECT_ID }} | |
| - name: Set gcloud project (quiet) | |
| run: | | |
| gcloud --quiet config set project "$GCP_PROJECT_ID" | |
| - name: Download artifacts from GCS | |
| run: | | |
| mkdir -p "${LOCAL_ARTIFACT_DIR}" | |
| gcloud storage cp "${CRASH_URI}" "${LOCAL_ARTIFACT_DIR}/crash_example.txt" | |
| gcloud storage cp "${ANR_URI}" "${LOCAL_ARTIFACT_DIR}/anr_example.txt" | |
| gcloud storage cp "${IMG_URI}" "${LOCAL_ARTIFACT_DIR}/1.png" | |
| echo "Downloaded files:" | |
| ls -la "${LOCAL_ARTIFACT_DIR}" | |
| - name: (Optional) POST artifacts as JSON to Cloud Run | |
| if: ${{ inputs.use_prod_service_url == true }} | |
| run: | | |
| set -euo pipefail | |
| CRASH_FILE="${LOCAL_ARTIFACT_DIR}/crash_example.txt" | |
| ANR_FILE="${LOCAL_ARTIFACT_DIR}/anr_example.txt" | |
| IMG_FILE="${LOCAL_ARTIFACT_DIR}/1.png" | |
| TOKEN="$(gcloud auth print-identity-token --audiences="${SERVICE_URL}")" | |
| PROMPT_FILE=".github/prompts/${{ inputs.prompt_file }}" | |
| PROMPT=$(<"$PROMPT_FILE") | |
| # Write combined crash + ANR content to a temp file | |
| CONTENT_FILE="$(mktemp)" | |
| { | |
| printf 'Crash:\n' | |
| cat "$CRASH_FILE" | |
| printf '\n\nANR:\n' | |
| cat "$ANR_FILE" | |
| } > "$CONTENT_FILE" | |
| # Post multipart form data: prompt, content (from file), and image | |
| RESPONSE_FILE="$(mktemp)" | |
| curl --fail-with-body -sS -X POST \ | |
| -H "Authorization: Bearer ${TOKEN}" \ | |
| -F "prompt=$(printf "%s" "$PROMPT")" \ | |
| -F "content=<${CONTENT_FILE};type=text/plain; charset=utf-8" \ | |
| -F "image=@${IMG_FILE};type=image/png" \ | |
| -o "$RESPONSE_FILE" \ | |
| "${SERVICE_URL}/analyze" | |
| # Extract output from JSON response and write to GitHub summary | |
| OUTPUT=$(jq -r '.output' "$RESPONSE_FILE") | |
| { | |
| echo "### 🧠 LLM Analysis Summary" | |
| echo "" | |
| echo "$OUTPUT" | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| rm -f "$CONTENT_FILE" "$RESPONSE_FILE" |