Daily AI Updates & Deploy to GitHub Pages #17
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 AI Updates & Deploy to GitHub Pages | |
| on: | |
| # Run daily at 6 AM UTC (once per day) | |
| schedule: | |
| - cron: '0 6 * * *' | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| # Run on push to main | |
| push: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| # Job 1: Generate AI content | |
| generate-content: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install Python dependencies | |
| run: | | |
| pip install yfinance pandas numpy scipy matplotlib | |
| - name: Run Moore Analysis | |
| run: | | |
| python market_analysis.py | |
| - name: Generate AI digest and insights | |
| env: | |
| OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} | |
| run: | | |
| # Create a simple Node.js script to generate content | |
| cat > generate.js << 'EOF' | |
| const fs = require('fs'); | |
| const apiKey = process.env.OPENROUTER_API_KEY || ''; | |
| const timestamp = new Date().toISOString(); | |
| // Inject API key into app.js | |
| let appContent = fs.readFileSync('app.js', 'utf8'); | |
| // Replace the API key placeholder | |
| appContent = appContent.replace( | |
| "apiKey: window.OPENROUTER_API_KEY || ''", | |
| `apiKey: '${apiKey}'` | |
| ); | |
| fs.writeFileSync('app.js', appContent); | |
| console.log('✅ API key injected successfully'); | |
| console.log(`📅 Generated at: ${timestamp}`); | |
| EOF | |
| node generate.js | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: updated-app | |
| path: | | |
| index.html | |
| styles.css | |
| app.js | |
| manifest.json | |
| service-worker.js | |
| icons/ | |
| README.md | |
| market_analysis.json | |
| market_analysis_chart.png | |
| retention-days: 1 | |
| # Job 2: Deploy to GitHub Pages | |
| deploy: | |
| needs: generate-content | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: updated-app | |
| path: . | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| with: | |
| enablement: true | |
| - name: Upload to Pages | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: '.' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Summary | |
| run: | | |
| echo "## 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ **Status**: Successfully deployed" >> $GITHUB_STEP_SUMMARY | |
| echo "🌐 **URL**: ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY | |
| echo "📅 **Time**: $(date)" >> $GITHUB_STEP_SUMMARY | |
| echo "🤖 **AI**: Content updated with fresh insights" >> $GITHUB_STEP_SUMMARY |