Xcode demands -scheme when using -derivedDataPath or -clonedSourcePackagesDirPath. Since we use -target TabataGo, these flags must be removed. Changes: - Removed -derivedDataPath and -clonedSourcePackagesDirPath from build command - Moved SWIFT_ENABLE_EXPLICIT_MODULES=NO to its own line for clarity - Updated Package IPA step to search from repo root (find ..) with explicit TabataGo.app name instead of relying on the old derived data path
156 lines
5.1 KiB
YAML
156 lines
5.1 KiB
YAML
# =============================================================================
|
|
# TabataGo — PR → Build → Archive → Firebase OTA → Wait LGTM → Merge
|
|
# =============================================================================
|
|
|
|
name: PR → Build → Firebase OTA → LGTM
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
types: [opened, synchronize, reopened]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
|
|
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: Setup PATH
|
|
run: echo "/opt/homebrew/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install tools (xcodegen, node, firebase)
|
|
run: |
|
|
brew install xcodegen node || true
|
|
npm install -g firebase-tools
|
|
|
|
- name: Generate Xcode project
|
|
run: |
|
|
cd tabatago-swift
|
|
xcodegen generate
|
|
|
|
- name: Resolve SPM packages
|
|
run: |
|
|
cd tabatago-swift
|
|
xcodebuild -resolvePackageDependencies -project TabataGo.xcodeproj -scmProvider system
|
|
|
|
- name: Build app
|
|
run: |
|
|
cd tabatago-swift
|
|
xcodebuild -list
|
|
xcodebuild build \
|
|
-project TabataGo.xcodeproj \
|
|
-target TabataGo \
|
|
-destination "generic/platform=iOS" \
|
|
-configuration Debug \
|
|
-allowProvisioningUpdates \
|
|
-skipPackagePluginValidation \
|
|
SWIFT_ENABLE_EXPLICIT_MODULES=NO \
|
|
CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=2MJF39L8VY
|
|
|
|
- name: Package IPA
|
|
run: |
|
|
cd tabatago-swift
|
|
mkdir -p Payload
|
|
APP=$(find .. -name 'TabataGo.app' -type d | grep -v DerivedData | head -1)
|
|
cp -R "$APP" Payload/
|
|
zip -r build/TabataGo.ipa Payload/
|
|
rm -rf Payload
|
|
|
|
- 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/f...on
|
|
firebase appdistribution:distribute tabatago-swift/build/TabataGo.ipa \
|
|
--app "${FIREBASE_APP_ID}" \
|
|
--groups "millian-test" \
|
|
--release-notes "PR: ${{ github.event.pull_request.title }}"
|
|
rm /tmp/firebase-key.json
|
|
|
|
- name: Post "Ready to test" comment
|
|
env:
|
|
GT_TOKEN: ${{ secrets.PR_API_TOKEN }}
|
|
GITEA_URL: https://gitea.1000co.fr
|
|
run: |
|
|
PR="${{ github.event.pull_request.number }}"
|
|
REPO="${{ github.repository }}"
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-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-approval:
|
|
name: Wait for LGTM comment
|
|
needs: build-deploy
|
|
runs-on: macos
|
|
timeout-minutes: 120
|
|
|
|
steps:
|
|
- name: Poll for LGTM
|
|
env:
|
|
GT_TOKEN: ${{ secrets.PR_API_TOKEN }}
|
|
GITEA_URL: https://gitea.1000co.fr
|
|
run: |
|
|
PR="${{ github.event.pull_request.number }}"
|
|
REPO="${{ github.repository }}"
|
|
PR_TITLE="${{ github.event.pull_request.title }}"
|
|
API="${GITEA_URL}/api/v1/repos/${REPO}"
|
|
MAX=240
|
|
TRIES=0
|
|
|
|
echo "⏳ Attente LGTM sur PR #${PR}..."
|
|
|
|
LAST_ID=$(curl -s -H "Authorization: token ${GT_TOKEN}" \
|
|
"${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 ]; do
|
|
sleep 30
|
|
TRIES=$((TRIES + 1))
|
|
|
|
COMMENTS=$(curl -s -H "Authorization: token ${GT_TOKEN}" \
|
|
"${API}/issues/${PR}/comments?since_id=${LAST_ID}")
|
|
|
|
if echo "$COMMENTS" | grep -qi '"body": *"LGTM"'; then
|
|
echo "✅ LGTM reçu ! Merge..."
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"Do\":\"merge\"}" \
|
|
"${API}/pulls/${PR}/merge"
|
|
echo "✅ Mergée."
|
|
exit 0
|
|
fi
|
|
|
|
if echo "$COMMENTS" | grep -qi '"body": *"KO"'; then
|
|
echo "❌ KO reçu. Bloquée."
|
|
exit 1
|
|
fi
|
|
|
|
if [ $((TRIES % 4)) -eq 0 ]; then
|
|
echo " ⏳ ... (${TRIES}/240, $(date +%H:%M))"
|
|
fi
|
|
done
|
|
echo "❌ Timeout 2h."
|
|
exit 1
|