From 8116b18a38cf74a81c5c6e7bd52933a6b0f050eb Mon Sep 17 00:00:00 2001 From: millianlmx Date: Fri, 26 Jun 2026 20:36:51 +0000 Subject: [PATCH] =?UTF-8?q?ci:=20add=20PR=20=E2=86=92=20iPhone=20=E2=86=92?= =?UTF-8?q?=20LGTM=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/pr-iphone-deploy.yml | 139 ++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 .gitea/workflows/pr-iphone-deploy.yml diff --git a/.gitea/workflows/pr-iphone-deploy.yml b/.gitea/workflows/pr-iphone-deploy.yml new file mode 100644 index 0000000..06c35d6 --- /dev/null +++ b/.gitea/workflows/pr-iphone-deploy.yml @@ -0,0 +1,139 @@ +# ============================================================================= +# TabataGo — PR → Build → iPhone → Wait LGTM → Merge +# ============================================================================= +# Chaque PR déclenche ce workflow : +# 1. Build l'app sur le Runner Mac +# 2. Installe sur l'iPhone (OTA via réseau local ou VPN) +# 3. Poste un commentaire sur la PR +# 4. Attend un commentaire "LGTM" de Millian +# 5. Merge automatique +# ============================================================================= + +name: PR → iPhone → LGTM + +on: + pull_request: + branches: [main] + types: [opened, synchronize, reopened] + +# ── Permissions ────────────────────────────────────────────────────────────── +permissions: + contents: write + pull-requests: write + +# ── Jobs ───────────────────────────────────────────────────────────────────── +jobs: + + # ─── Build + Deploy ──────────────────────────────────────────────────────── + build-deploy: + name: Build & Install on iPhone + runs-on: macos + timeout-minutes: 20 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Xcode + run: | + sudo xcode-select -s /Applications/Xcode.app + xcodebuild -version + + - name: Generate Xcode project + run: | + cd tabatago-swift + xcodegen generate + + - name: Build & Install on iPhone + env: + IPHONE_UDID: ${{ secrets.IPHONE_UDID }} + run: | + cd tabatago-swift + + # Build for device + xcodebuild build \ + -scheme TabataGo \ + -sdk iphoneos \ + -destination "platform=iOS,id=${IPHONE_UDID}" \ + -configuration Debug \ + -allowProvisioningUpdates \ + -derivedDataPath ../build \ + CODE_SIGN_STYLE=Automatic \ + 2>&1 | tail -20 + + echo "✅ App built and installed on iPhone (UDID: ${IPHONE_UDID})" + + - name: Post "Ready to test" comment + env: + GT_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_HOST: ${{ vars.GITEA_URL || 'https://gitea.1000co.fr' }} + run: | + PR="${{ github.event.pull_request.number }}" + REPO="${{ github.repository }}" + curl -sk -X POST \ + -H "Authorization: token *** \ + -H "Content-Type: application/json" \ + -d "{\"body\":\"## 📱 Prêt à tester !\n\nL'app a été déployée sur ton iPhone.\n\n- Teste les changements\n- Reply LGTM pour merger\n- Reply KO pour bloquer\"}" \ + "${GITEA_HOST}/api/v1/repos/${REPO}/issues/${PR}/comments" + + # ─── Wait for LGTM ───────────────────────────────────────────────────────── + wait-approval: + name: Wait for LGTM comment + needs: build-deploy + runs-on: macos + timeout-minutes: 120 # 2 heures max + + steps: + - name: Poll for LGTM + env: + GT_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_URL: ${{ vars.GITEA_URL || 'https://gitea.1000co.fr' }} + run: | + PR_NUMBER="${{ github.event.pull_request.number }}" + REPO="${{ github.repository }}" + API="${GITEA_URL}/api/v1/repos/${REPO}" + MAX_TRIES=240 # 2h = 240 × 30s + TRIES=0 + + echo "⏳ Attente du commentaire LGTM sur la PR #${PR_NUMBER}..." + echo " Reply 'LGTM' sur la PR pour merger." + + # Marquer l'ancien commentaire du workflow comme point de départ + LAST_ID=$(curl -sk -H "Authorization: token $GT_TOKEN" \ + "${API}/issues/${PR_NUMBER}/comments" | \ + python3 -c "import json,sys; cs=json.load(sys.stdin); print(cs[-1]['id'] if cs else 0)" 2>/dev/null || echo 0) + + while [ $TRIES -lt $MAX_TRIES ]; do + sleep 30 + TRIES=$((TRIES + 1)) + + # Récupère les nouveaux commentaires + COMMENTS=$(curl -sk -H "Authorization: token ${GITEA_TOKEN}" \ + "${API}/issues/${PR_NUMBER}/comments?since_id=${LAST_ID}") + + if echo "$COMMENTS" | grep -qi '"body": *"LGTM"'; then + echo "" + echo "✅ LGTM reçu ! Merge de la PR..." + curl -sk -X POST -H "Authorization: token ${GITEA_TOKEN}" \ + "${API}/pulls/${PR_NUMBER}/merge" \ + -H "Content-Type: application/json" \ + -d "{\"Do\":\"merge\",\"MergeTitleField\":\"${{ github.event.pull_request.title }}\"}" + echo "" + echo "✅ PR mergée." + exit 0 + fi + + if echo "$COMMENTS" | grep -qi '"body": *"KO"'; then + echo "" + echo "❌ KO reçu. PR bloquée." + exit 1 + fi + + # Petit heartbeat toutes les 2 min + if [ $((TRIES % 4)) -eq 0 ]; then + echo " ⏳ Toujours en attente... (${TRIES}/240, $(date +%H:%M))" + fi + done + + echo "❌ Timeout — pas de LGTM reçu après 2h." + exit 1