From 1b3ce24fc998b67133239d556337d26fe2495b3f Mon Sep 17 00:00:00 2001 From: millianlmx Date: Fri, 26 Jun 2026 22:31:09 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20complete=20rewrite=20=E2=80=94=20add=20g?= =?UTF-8?q?it=20clone=20checkout,=20install=20node+npm,=20fix=20all=20path?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/pr-iphone-deploy.yml | 77 +++++++++++---------------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/.gitea/workflows/pr-iphone-deploy.yml b/.gitea/workflows/pr-iphone-deploy.yml index 0e4adca..778e23c 100644 --- a/.gitea/workflows/pr-iphone-deploy.yml +++ b/.gitea/workflows/pr-iphone-deploy.yml @@ -1,13 +1,6 @@ # ============================================================================= # TabataGo — PR → Build → Archive → Firebase OTA → Wait LGTM → Merge # ============================================================================= -# Chaque PR déclenche ce workflow : -# 1. Build l'app sur le Runner Mac -# 2. Archive → Export .ipa → Déploie via Firebase App Distribution -# 3. Poste un commentaire sur la PR -# 4. Attend un commentaire "LGTM" de Millian -# 5. Merge automatique -# ============================================================================= name: PR → Build → Firebase OTA → LGTM @@ -16,37 +9,40 @@ on: branches: [main] types: [opened, synchronize, reopened] -# ── Permissions ────────────────────────────────────────────────────────────── permissions: contents: write pull-requests: write -# ── Jobs ───────────────────────────────────────────────────────────────────── jobs: - # ─── Build + Deploy ──────────────────────────────────────────────────────── build-deploy: name: Build & Deploy to Firebase OTA runs-on: macos timeout-minutes: 20 steps: + - name: Checkout + run: | + git clone --depth 1 https://x-access-token:${PR_TOKEN}@gitea.1000co.fr/${REPO}.git . + env: + PR_TOKEN: ${{ secrets.PR_API_TOKEN }} + REPO: ${{ github.repository }} + - name: Setup Xcode run: | sudo xcode-select -s /Applications/Xcode.app xcodebuild -version - - name: Install xcodegen - run: arch -arm64 /opt/homebrew/bin/brew install xcodegen + - name: Install tools (xcodegen, node, firebase) + run: | + arch -arm64 /opt/homebrew/bin/brew install xcodegen node + npm install -g firebase-tools - name: Generate Xcode project run: | cd tabatago-swift xcodegen generate - - name: Install Firebase CLI - run: npm install -g firebase-tools - - name: Archive app run: | cd tabatago-swift @@ -61,19 +57,20 @@ jobs: - name: Export IPA run: | + cd tabatago-swift xcodebuild -exportArchive \ -archivePath ../build/TabataGo.xcarchive \ -exportPath ../build/ \ -exportOptionsPlist ExportOptions.plist \ -allowProvisioningUpdates - - name: Deploy to Firebase App Distribution + - name: Deploy to Firebase env: FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} run: | echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" | base64 -d > /tmp/firebase-key.json - export GOOGLE_APPLICATION_CREDENTIALS=/tmp/firebase-key.json - firebase appdistribution:distribute ../build/TabataGo.ipa \ + export GOOGLE_APPLICATION_CREDENTIALS=/tmp/f...on + firebase appdistribution:distribute build/TabataGo.ipa \ --app "${FIREBASE_APP_ID}" \ --groups "millian-test" \ --release-notes "PR: ${{ github.event.pull_request.title }}" @@ -82,77 +79,67 @@ jobs: - name: Post "Ready to test" comment env: GT_TOKEN: ${{ secrets.PR_API_TOKEN }} - GITEA_URL: ${{ vars.GITEA_URL || 'https://gitea.1000co.fr' }} + GITEA_URL: https://gitea.1000co.fr run: | PR="${{ github.event.pull_request.number }}" REPO="${{ github.repository }}" - BODY="## 📱 Prêt à tester !\\n\\nL'app a été déployée via Firebase App Distribution.\\n\\n- Teste les changements\\n- Reply **LGTM** pour merger\\n- Reply **KO** pour bloquer" curl -s -X POST \ -H "Authorization: token ${GT_TOKEN}" \ -H "Content-Type: application/json" \ - -d "{\"body\": \"${BODY}\"}" \ + -d "{\"body\":\"## 📱 Prêt à tester !\\n\\nL\'app est déployée via Firebase.\\n\\n- Teste les changements\\n- Reply **LGTM** pour merger\\n- Reply **KO** pour bloquer\"}" \ "${GITEA_URL}/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 + timeout-minutes: 120 steps: - name: Poll for LGTM env: GT_TOKEN: ${{ secrets.PR_API_TOKEN }} - GITEA_URL: ${{ vars.GITEA_URL || 'https://gitea.1000co.fr' }} + GITEA_URL: https://gitea.1000co.fr run: | - PR_NUMBER="${{ github.event.pull_request.number }}" + PR="${{ github.event.pull_request.number }}" REPO="${{ github.repository }}" PR_TITLE="${{ github.event.pull_request.title }}" API="${GITEA_URL}/api/v1/repos/${REPO}" - MAX_TRIES=240 # 2h = 240 × 30s + MAX=240 TRIES=0 - echo "⏳ Attente du commentaire LGTM sur la PR #${PR_NUMBER}..." - echo " Reply 'LGTM' sur la PR pour merger." + echo "⏳ Attente LGTM sur PR #${PR}..." - # Marquer l'ancien commentaire du workflow comme point de départ LAST_ID=$(curl -s -H "Authorization: token ${GT_TOKEN}" \ - "${API}/issues/${PR_NUMBER}/comments" | \ + "${API}/issues/${PR}/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 + while [ $TRIES -lt $MAX ]; do sleep 30 TRIES=$((TRIES + 1)) - # Récupère les nouveaux commentaires COMMENTS=$(curl -s -H "Authorization: token ${GT_TOKEN}" \ - "${API}/issues/${PR_NUMBER}/comments?since_id=${LAST_ID}") + "${API}/issues/${PR}/comments?since_id=${LAST_ID}") if echo "$COMMENTS" | grep -qi '"body": *"LGTM"'; then - echo "" - echo "✅ LGTM reçu ! Merge de la PR..." + echo "✅ LGTM reçu ! Merge..." curl -s -X POST \ -H "Authorization: token ${GT_TOKEN}" \ -H "Content-Type: application/json" \ - -d "{\"Do\":\"merge\",\"MergeTitleField\":\"${PR_TITLE}\"}" \ - "${API}/pulls/${PR_NUMBER}/merge" - echo "" - echo "✅ PR mergée." + -d "{\"Do\":\"merge\"}" \ + "${API}/pulls/${PR}/merge" + echo "✅ Mergée." exit 0 fi if echo "$COMMENTS" | grep -qi '"body": *"KO"'; then - echo "" - echo "❌ KO reçu. PR bloquée." + echo "❌ KO reçu. 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))" + echo " ⏳ ... (${TRIES}/240, $(date +%H:%M))" fi done - - echo "❌ Timeout — pas de LGTM reçu après 2h." + echo "❌ Timeout 2h." exit 1