[BUG] I ask to do things but when is time to do a PR just crash?

Resolved 💬 2 comments Opened Jun 12, 2025 by Gameadictive Closed Aug 12, 2025

What version of Codex is running?

the web version

Which model were you using?

codex

What platform is your computer?

windows 11

What steps can reproduce the bug?

This in the codex web enviroment

#!/bin/bash

# 1️⃣ Instalar Godot 4.4.1 en Linux
GODOT_VERSION="4.4.1"
GODOT_URL="https://github.com/godotengine/godot/releases/download/4.4.1-stable/Godot_v4.4.1-stable_linux.x86_64.zip"

echo "Instalando Godot ${GODOT_VERSION}..."
curl -L -o godot.zip "${GODOT_URL}"
unzip -q godot.zip -d godot_bin
chmod +x godot_bin/Godot_v${GODOT_VERSION}-stable_linux.x86_64
# Mueve el ejecutable a una ruta accesible
mv godot_bin/Godot_v${GODOT_VERSION}-stable_linux.x86_64 /usr/local/bin/godot
rm -rf godot.zip godot_bin

# Verificar instalación
echo "Godot instalado:"
godot --version || echo "⚠️ No se pudo ejecutar 'godot --version'"

# 2️⃣ Configurar Git
git config --global user.email "***************"
git config --global user.name "Codex Bot"

# 📁 Variables del repositorio
REPO_NAME="*************"
REPO_OWNER="************"
BRANCH_NAME="********"
MAIN_BRANCH="main"
REPO_DIR="/workspace/${REPO_NAME}"
REPO_URL="https://${REPO_OWNER}:${GH_TOKEN}@github.com/${REPO_OWNER}/${REPO_NAME}.git"
PR_API="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/pulls"

# 3️⃣ Clonar si no existe
if [ ! -d "${REPO_DIR}/.git" ]; then
  git clone "${REPO_URL}" "${REPO_DIR}"
fi
cd "${REPO_DIR}"

# 4️⃣ Asegurar remote correcto
if git remote get-url origin > /dev/null 2>&1; then
  git remote set-url origin "${REPO_URL}"
else
  git remote add origin "${REPO_URL}"
fi
git fetch origin

# 5️⃣ Checkout o sincronización de la rama dev_test
if git show-ref --quiet refs/heads/${BRANCH_NAME}; then
  git checkout ${BRANCH_NAME}
  git pull --rebase origin ${BRANCH_NAME}
else
  git checkout -b ${BRANCH_NAME} origin/${BRANCH_NAME} || git checkout -b ${BRANCH_NAME}
fi

# 6️⃣ Commit + Push automático si hay cambios
if ! git diff --quiet || ! git diff --cached --quiet; then
  git add .
  git commit -m "Commit automático desde Codex"
  git push origin ${BRANCH_NAME}
else
  echo "No hay cambios para commitear."
fi

# 7️⃣ Crear Pull Request si no existe y hay commits nuevos
EXISTE_PR=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
  "${PR_API}?head=${REPO_OWNER}:${BRANCH_NAME}" | jq length)

if [ "$EXISTE_PR" -eq 0 ]; then
  COMMITS=$(git rev-list origin/${MAIN_BRANCH}..origin/${BRANCH_NAME} --count)
  if [ "$COMMITS" -gt 0 ]; then
    echo "Creando Pull Request automático desde ${BRANCH_NAME} a ${MAIN_BRANCH}..."
    curl -X POST -H "Authorization: token ${GH_TOKEN}" \
      -H "Accept: application/vnd.github.v3+json" \
      -d "{\"title\":\"PR automático desde Codex\", \"head\":\"${BRANCH_NAME}\", \"base\":\"${MAIN_BRANCH}\", \"body\":\"Este PR fue generado automáticamente desde Codex.\"}" \
      "${PR_API}"
  else
    echo "No hay commits nuevos entre ${BRANCH_NAME} y ${MAIN_BRANCH}. No se crea PR."
  fi
else
  echo "Ya existe un Pull Request desde ${BRANCH_NAME}."
fi

What is the expected behavior?

To make his work correctly without problems.

What do you see instead?

!Image

Additional information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗