chore: prettier formatting #213
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: iOS Telegram Notification | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - "client/**" | |
| - "scripts/**" | |
| - "package.json" | |
| - "bun.lock" | |
| - ".github/workflows/**" | |
| - "!**/*.md" | |
| jobs: | |
| build: | |
| name: Build iOS Device App | |
| uses: ./.github/workflows/ios-device-build.yml | |
| with: | |
| variant: signet | |
| secrets: inherit | |
| upload_and_notify: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: π₯ Download IPA artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ${{ needs.build.outputs.artifact_name }} | |
| path: . | |
| - name: π€ Upload to Diawi | |
| id: upload_diawi | |
| run: | | |
| response=$(curl -s -X POST "https://upload.diawi.com/" \ | |
| -F token="${{ secrets.DIAWI_TOKEN }}" \ | |
| -F file=@"${{ needs.build.outputs.ipa_filename }}") | |
| echo "Upload response: ${response}" | |
| job_token=$(echo "$response" | jq -r '.job') | |
| if [ "$job_token" == "null" ] || [ -z "$job_token" ]; then | |
| echo "Failed to get job token from Diawi" | |
| echo "$response" | jq . | |
| exit 1 | |
| fi | |
| echo "job_token=${job_token}" >> $GITHUB_OUTPUT | |
| echo "Upload started with job token: ${job_token}" | |
| - name: β³ Poll Diawi for completion | |
| id: poll_diawi | |
| run: | | |
| max_attempts=30 | |
| attempt=0 | |
| while [ $attempt -lt $max_attempts ]; do | |
| echo "Polling attempt $((attempt + 1))/${max_attempts}..." | |
| response=$(curl -s "https://upload.diawi.com/status?token=${{ secrets.DIAWI_TOKEN }}&job=${{ steps.upload_diawi.outputs.job_token }}") | |
| status=$(echo "$response" | jq -r '.status') | |
| echo "Status: ${status}" | |
| if [ "$status" == "2000" ]; then | |
| link=$(echo "$response" | jq -r '.link') | |
| qrcode=$(echo "$response" | jq -r '.qrcode') | |
| echo "diawi_link=${link}" >> $GITHUB_OUTPUT | |
| echo "diawi_qrcode=${qrcode}" >> $GITHUB_OUTPUT | |
| echo "β Upload complete! Link: ${link}" | |
| exit 0 | |
| elif [ "$status" == "2001" ]; then | |
| message=$(echo "$response" | jq -r '.message // "Processing..."') | |
| echo "β³ ${message}" | |
| sleep 2 | |
| attempt=$((attempt + 1)) | |
| else | |
| error=$(echo "$response" | jq -r '.message // "Unknown error"') | |
| echo "β Upload failed with status ${status}: ${error}" | |
| echo "$response" | jq . | |
| exit 1 | |
| fi | |
| done | |
| echo "β±οΈ Timeout waiting for upload to complete after $((max_attempts * 2)) seconds" | |
| exit 1 | |
| - name: π Prepare Telegram message | |
| if: success() | |
| env: | |
| COMMIT_SHA: ${{ github.sha }} | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| DIAWI_LINK: ${{ steps.poll_diawi.outputs.diawi_link }} | |
| run: | | |
| python3 <<'PY' | |
| import os | |
| from pathlib import Path | |
| sha = os.environ["COMMIT_SHA"] | |
| commit_message = os.environ.get("COMMIT_MESSAGE", "").strip() or "(no commit message)" | |
| diawi_link = os.environ["DIAWI_LINK"] | |
| message = ( | |
| "π New Noah iOS build is available!\n\n" | |
| f"π₯ Download: {diawi_link}\n\n" | |
| f"π Commit: {sha}\n" | |
| f"π¬ Message: {commit_message}" | |
| ) | |
| # Telegram sendMessage allows 4096 chars. Keep margin for UTF-8 edge cases. | |
| max_message_chars = 3900 | |
| if len(message) > max_message_chars: | |
| message = f"{message[: max_message_chars - 1]}β¦" | |
| Path("telegram_ios_build_message.txt").write_text(message, encoding="utf-8") | |
| PY | |
| - name: π’ Send to Telegram | |
| if: success() | |
| run: | | |
| curl -fsS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \ | |
| -F chat_id="${{ secrets.BLIXT_CHAT_ID }}" \ | |
| -F message_thread_id="${{ secrets.BLIXT_TOPIC_ID }}" \ | |
| -F "text=<telegram_ios_build_message.txt" |