Model Scanner #1727
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: Model Scanner | |
| on: | |
| schedule: | |
| # Run every hour | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| scan: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ github.token }} | |
| fetch-depth: 1 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Ensure logs folder exists | |
| run: mkdir -p logs | |
| - name: Run model scan | |
| env: | |
| WEBHOOK: ${{ secrets.WEBHOOK }} | |
| WEBHOOK_SMALL: ${{ secrets.WEBHOOK_SMALL }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| OLLAMA_API_KEY: ${{ secrets.OLLAMA_API_KEY }} | |
| LOCALAI_API_KEY: ${{ secrets.LOCALAI_API_KEY }} | |
| TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }} | |
| GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} | |
| FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }} | |
| DEEPINFRA_API_KEY: ${{ secrets.DEEPINFRA_API_KEY }} | |
| MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} | |
| COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} | |
| GH_MODELS_API_KEY: ${{ secrets.GH_MODELS_API_KEY }} | |
| ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }} | |
| XAI_API_KEY: ${{ secrets.XAI_API_KEY }} | |
| run: npm run scan | |
| - name: Upload logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: scan-logs | |
| path: logs/ | |
| retention-days: 7 | |
| - name: Cleanup old logs | |
| run: | | |
| # Clean up logs older than 30 days | |
| find logs -type f -mtime +30 -delete | |
| - name: Commit results to master | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Configure git with token | |
| git config --global user.name "ModelWatcher" | |
| git config --global user.email "modelwatcher@github.com" | |
| # Save the new scan state before resetting | |
| cp logs/state.json /tmp/state-new.json 2>/dev/null || true | |
| # Fetch latest and reset to handle concurrent runs | |
| git fetch origin master | |
| git reset --hard origin/master | |
| # Create logs dir and copy new state if we have one | |
| mkdir -p logs | |
| if [ -f /tmp/state-new.json ]; then | |
| cp /tmp/state-new.json logs/state.json | |
| fi | |
| # Copy scan results to logs folder | |
| cp logs/scan-*.json logs/ 2>/dev/null || true | |
| # Check if there are actual changes to commit | |
| # Compare new state.json with origin's (if it exists) | |
| if [ -f logs/state.json ]; then | |
| ORIG_HASH=$(git show origin/master:logs/state.json 2>/dev/null | sha256sum | cut -d' ' -f1 || echo "empty") | |
| NEW_HASH=$(sha256sum logs/state.json | cut -d' ' -f1) | |
| if [ "$ORIG_HASH" = "$NEW_HASH" ] && [ "$ORIG_HASH" != "empty" ]; then | |
| echo "No model changes detected - skipping commit" | |
| exit 0 | |
| fi | |
| fi | |
| # Add and commit (only if there are changes) | |
| # Force add only state.json since scan files have timestamps | |
| git add -f logs/state.json || true | |
| if ! git diff --quiet --staged; then | |
| git commit -m "Update logs - $(date -u +'%Y-%m-%d %H:%M UTC')" | |
| git push origin master | |
| echo "Updated logs on master branch" | |
| else | |
| echo "No changes to commit" | |
| fi |