Skip to content

chore: prettier formatting #213

chore: prettier formatting

chore: prettier formatting #213

Workflow file for this run

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"