Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/reset-failed-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Reset Failed Builds

on:
workflow_dispatch:
inputs:
buildId:
description: 'Optional: specific build ID to reset (leave empty to reset ALL maxed-out builds)'
required: false
default: ''
confirm:
description: 'Type "yes" to confirm reset of failure counts'
required: true
default: ''

jobs:
reset:
name: Reset failed build counts
runs-on: ubuntu-latest
if: ${{ github.event.inputs.confirm == 'yes' }}
steps:
- name: Reset failure counts
run: |
BUILD_ID="${{ github.event.inputs.buildId }}"

if [ -n "$BUILD_ID" ]; then
echo "Resetting failure count for build: $BUILD_ID"
PAYLOAD="{\"buildId\": \"$BUILD_ID\"}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verifies current interpolation can produce invalid JSON.
BUILD_ID='editor-linux-"bad"-id'
PAYLOAD="{\"buildId\": \"$BUILD_ID\"}"
echo "$PAYLOAD" | jq . >/dev/null

Repository: game-ci/docker

Length of output: 115


🏁 Script executed:

cat .github/workflows/reset-failed-builds.yml

Repository: game-ci/docker

Length of output: 1638


🏁 Script executed:

#!/bin/bash
# Verify the proposed jq fix works with problematic BUILD_ID
BUILD_ID='editor-linux-"bad"-id'
PAYLOAD=$(jq -n --arg buildId "$BUILD_ID" '{buildId: $buildId}')
echo "$PAYLOAD" | jq . >/dev/null && echo "Valid JSON: $PAYLOAD"

Repository: game-ci/docker

Length of output: 112


Safely escape buildId when constructing JSON payload.

The code directly interpolates user input (github.event.inputs.buildId) into the JSON string, which will produce invalid JSON if the input contains quotes or backslashes. Use jq --arg to safely construct the payload:

Proposed fix
          if [ -n "$BUILD_ID" ]; then
            echo "Resetting failure count for build: $BUILD_ID"
-           PAYLOAD="{\"buildId\": \"$BUILD_ID\"}"
+           PAYLOAD=$(jq -n --arg buildId "$BUILD_ID" '{buildId: $buildId}')
          else
            echo "Resetting ALL failed builds at max retries..."
            PAYLOAD="{}"
          fi
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
PAYLOAD="{\"buildId\": \"$BUILD_ID\"}"
if [ -n "$BUILD_ID" ]; then
echo "Resetting failure count for build: $BUILD_ID"
PAYLOAD=$(jq -n --arg buildId "$BUILD_ID" '{buildId: $buildId}')
else
echo "Resetting ALL failed builds at max retries..."
PAYLOAD="{}"
fi
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/reset-failed-builds.yml at line 27, The PAYLOAD
construction currently interpolates BUILD_ID directly into a JSON string which
will break for quotes/backslashes; change the logic that sets PAYLOAD (the
PAYLOAD variable that uses BUILD_ID) to build the JSON safely using jq --arg
(e.g., echo '{}' | jq --arg buildId "$BUILD_ID" '.buildId = $buildId') or an
equivalent jq command so BUILD_ID is properly escaped and valid JSON is
produced.

else
echo "Resetting ALL failed builds at max retries..."
PAYLOAD="{}"
fi

RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer ${{ secrets.VERSIONING_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"https://europe-west3-unity-ci-versions.cloudfunctions.net/resetFailedBuilds")

HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -n -1)

echo "HTTP Status: $HTTP_CODE"
echo "$BODY" | jq . 2>/dev/null || echo "$BODY"

if [ "$HTTP_CODE" -ne 200 ]; then
echo "::error::Reset request failed with status $HTTP_CODE"
exit 1
fi

echo "::notice::Reset completed successfully"
Loading