fix: update workflows and docs for Render deployment #46
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: Daily Report | ||
| on: | ||
| schedule: | ||
| # Run at 00:00 UTC every day | ||
| - cron: '0 0 * * *' | ||
| workflow_dispatch: | ||
| jobs: | ||
| generate-report: | ||
| name: Generate Daily Report | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install -r reports/requirements.txt | ||
| - name: Fetch data from Render API | ||
| env: | ||
| RENDER_SERVICE_URL: ${{ secrets.RENDER_SERVICE_URL }} | ||
| run: | | ||
| # Use secret URL or fallback to default service name | ||
| SERVICE_URL="${RENDER_SERVICE_URL:-https://orp-flow-trading.onrender.com}" | ||
| echo "📊 Fetching trading data from: $SERVICE_URL" | ||
| mkdir -p data | ||
| # Fetch metrics | ||
| echo "Fetching /metrics..." | ||
| curl -s "$SERVICE_URL/metrics" --connect-timeout 30 --max-time 60 > data/metrics.json || echo '{}' > data/metrics.json | ||
| # Fetch trades history | ||
| echo "Fetching /trades..." | ||
| curl -s "$SERVICE_URL/trades" --connect-timeout 30 --max-time 60 > data/trades.json || echo '[]' > data/trades.json | ||
| # Fetch account status | ||
| echo "Fetching /account..." | ||
| curl -s "$SERVICE_URL/account" --connect-timeout 30 --max-time 60 > data/account.json || echo '{}' > data/account.json | ||
| # Show fetched data summary | ||
| echo "" | ||
| echo "📈 Fetched data summary:" | ||
| echo "Metrics:" | ||
| cat data/metrics.json | jq . 2>/dev/null || cat data/metrics.json | ||
| echo "" | ||
| echo "Trades count: $(cat data/trades.json | jq 'length' 2>/dev/null || echo 'N/A')" | ||
| echo "Account:" | ||
| cat data/account.json | jq . 2>/dev/null || cat data/account.json | ||
| - name: Generate report | ||
| env: | ||
| DATA_SOURCE: api | ||
| run: | | ||
| python reports/generate.py | ||
| - name: Commit and push changes | ||
| run: | | ||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --local user.name "github-actions[bot]" | ||
| git add reports/assets/ README.md | ||
| git diff --staged --quiet || git commit -m "Update daily performance report [skip ci]" | ||
| git push | ||
| - name: Send Telegram notification | ||
| if: success() | ||
| env: | ||
| TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
| TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | ||
| run: | | ||
| if [ -n "$TELEGRAM_BOT_TOKEN" ] && [ -n "$TELEGRAM_CHAT_ID" ]; then | ||
| # Extract key metrics for notification | ||
| TOTAL_TRADES=$(cat data/metrics.json | jq -r '.total_trades // 0' 2>/dev/null || echo "0") | ||
| WIN_RATE=$(cat data/metrics.json | jq -r '.win_rate // 0' 2>/dev/null || echo "0") | ||
| TOTAL_PNL=$(cat data/metrics.json | jq -r '.total_pnl // 0' 2>/dev/null || echo "0") | ||
| MESSAGE="📊 ORPFlow Daily Report Generated | ||
| 📈 Performance Summary: | ||
| • Total Trades: $TOTAL_TRADES | ||
| • Win Rate: ${WIN_RATE}% | ||
| • Total P&L: \$${TOTAL_PNL} | ||
| Check the updated README for full metrics and charts." | ||
| curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \ | ||
| -d "chat_id=${TELEGRAM_CHAT_ID}" \ | ||
| -d "text=${MESSAGE}" \ | ||
| -d "parse_mode=HTML" | ||
| fi | ||