fix: update GitHub Actions workflow to only trigger on manual dispatc⦠#13
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: Fetch AI Models | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| providers: | ||
| description: 'Comma-separated list of providers to fetch (leave empty for all)' | ||
| required: false | ||
| default: '' | ||
| push: | ||
| tags: | ||
| - 'release-*.*.*' | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| jobs: | ||
| fetch-and-update: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| - name: Cache Cargo dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| target/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| - name: Build project | ||
| run: cargo build --release | ||
| - name: Run tests | ||
| run: cargo test | ||
| - name: Create dist directory | ||
| run: mkdir -p dist | ||
| - name: Fetch model data | ||
| run: | | ||
| if [ -n "${{ github.event.inputs.providers }}" ]; then | ||
| cargo run --release -- fetch-providers -p "${{ github.event.inputs.providers }}" -o dist | ||
| else | ||
| cargo run --release -- fetch-all -o dist | ||
| fi | ||
| env: | ||
| # Add API keys as secrets if needed | ||
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} | ||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||
| - name: Validate generated JSON files | ||
| run: | | ||
| echo "Validating JSON files..." | ||
| for file in dist/*.json; do | ||
| if [ -f "$file" ]; then | ||
| echo "Validating $file" | ||
| jq empty "$file" || (echo "Invalid JSON in $file" && exit 1) | ||
| fi | ||
| done | ||
| - name: List generated files | ||
| run: | | ||
| echo "Generated files:" | ||
| ls -la dist/ | ||
| echo "File sizes:" | ||
| du -h dist/*.json | ||
| - name: Generate release info | ||
| id: release_info | ||
| run: | | ||
| # Extract provider information from all.json | ||
| if [ -f "dist/all.json" ]; then | ||
| TOTAL_MODELS=$(jq -r '.totalModels' dist/all.json) | ||
| PROVIDERS=$(jq -r '.providers | keys | join(", ")' dist/all.json) | ||
| PROVIDER_COUNT=$(jq -r '.providers | keys | length' dist/all.json) | ||
| echo "total_models=$TOTAL_MODELS" >> $GITHUB_OUTPUT | ||
| echo "providers=$PROVIDERS" >> $GITHUB_OUTPUT | ||
| echo "provider_count=$PROVIDER_COUNT" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "total_models=0" >> $GITHUB_OUTPUT | ||
| echo "providers=none" >> $GITHUB_OUTPUT | ||
| echo "provider_count=0" >> $GITHUB_OUTPUT | ||
| fi | ||
| # Generate timestamp | ||
| echo "timestamp=$(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT | ||
| echo "date_short=$(date -u '+%Y%m%d')" >> $GITHUB_OUTPUT | ||
| - name: Create Pull Request with updates | ||
| if: github.ref_type != 'tag' && github.event_name == 'workflow_dispatch' | ||
| run: | | ||
| git config --local user.email "[email protected]" | ||
| git config --local user.name "GitHub Action" | ||
| # Copy generated files to provider_configs for direct access | ||
| cp -r dist/* provider_configs/ || true | ||
| # Check if there are changes | ||
| git add provider_configs/ | ||
| if ! git diff --staged --quiet; then | ||
| # Create a new branch for the PR | ||
| BRANCH_NAME="update-models-$(date -u +%Y%m%d-%H%M%S)" | ||
| git checkout -b "$BRANCH_NAME" | ||
| # Commit changes | ||
| git commit -m "π€ Update model configurations - $(date -u +%Y-%m-%d)" | ||
| # Push to remote | ||
| git push origin "$BRANCH_NAME" | ||
| # Create PR using GitHub CLI | ||
| TIMESTAMP="${{ steps.release_info.outputs.timestamp }}" | ||
| TOTAL_MODELS="${{ steps.release_info.outputs.total_models }}" | ||
| PROVIDER_COUNT="${{ steps.release_info.outputs.provider_count }}" | ||
| PROVIDERS="${{ steps.release_info.outputs.providers }}" | ||
| gh pr create \ | ||
| --title "π€ Update AI Model Configurations" \ | ||
| --body "## π€ Automated Model Configuration Update | ||
| **Generated:** ${TIMESTAMP} | ||
| **Total Models:** ${TOTAL_MODELS} | ||
| **Providers:** ${PROVIDER_COUNT} (${PROVIDERS}) | ||
| ### π Changes | ||
| - Updated model configurations from provider APIs | ||
| - Refreshed capability detection (vision, function calling, reasoning) | ||
| - Generated standardized JSON format files | ||
| ### π Files Updated | ||
| - \`provider_configs/*.json\` - Individual provider configurations | ||
| - \`provider_configs/all.json\` - Aggregated model data | ||
| ### β Validation | ||
| - [x] JSON syntax validation passed | ||
| - [x] Model data structure validation passed | ||
| - [x] Provider capability detection completed | ||
| --- | ||
| *This PR was automatically created by GitHub Actions.*" \ | ||
| --head "$BRANCH_NAME" \ | ||
| --base main | ||
| else | ||
| echo "No changes to commit" | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Create Release Assets | ||
| if: github.ref_type == 'tag' | ||
| run: | | ||
| # Create tarball of all JSON files with proper naming | ||
| cd dist | ||
| TAG_NAME="${{ github.ref_name }}" | ||
| tar -czf "../provider-configs-${TAG_NAME}.tar.gz" *.json | ||
| # Also create individual provider archives | ||
| for file in *.json; do | ||
| if [ "$file" != "all.json" ]; then | ||
| provider_name=$(basename "$file" .json) | ||
| tar -czf "../${provider_name}-${TAG_NAME}.tar.gz" "$file" | ||
| fi | ||
| done | ||
| cd .. | ||
| - name: Upload Artifacts (non-tag) | ||
| if: github.ref_type != 'tag' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: provider-configs-${{ steps.release_info.outputs.date_short }} | ||
| path: | | ||
| dist/*.json | ||
| retention-days: 30 | ||
| - name: Create Release (tagged) | ||
| if: github.ref_type == 'tag' | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| name: Release ${{ github.ref_name }} | ||
| body: | | ||
| π·οΈ **Tagged Release of AI Model Configurations** | ||
| **Release Version:** ${{ github.ref_name }} | ||
| **Generated:** ${{ steps.release_info.outputs.timestamp }} | ||
| **Total Models:** ${{ steps.release_info.outputs.total_models }} | ||
| **Providers:** ${{ steps.release_info.outputs.provider_count }} (${{ steps.release_info.outputs.providers }}) | ||
| ## π¦ Available Downloads | ||
| ### Complete Package | ||
| - `provider-configs-${{ github.ref_name }}.tar.gz` - All provider configurations | ||
| ### Individual Provider Packages | ||
| Available individual provider archives for selective downloading. | ||
| ### Raw JSON Files | ||
| Individual JSON files are also available as release assets for direct access. | ||
| ## π Provider Details | ||
| | Provider | Models Available | | ||
| |----------|-----------------| | ||
| ${{ steps.release_info.outputs.providers != 'none' && '| Multiple providers | See all.json |' || '| No providers | 0 |' }} | ||
| ## π Integration | ||
| ### Direct JSON Access | ||
| ```javascript | ||
| // Access aggregated data | ||
| const response = await fetch('https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/all.json'); | ||
| const modelData = await response.json(); | ||
| ``` | ||
| ### Complete Package Download | ||
| ```bash | ||
| wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/provider-configs-${{ github.ref_name }}.tar.gz | ||
| tar -xzf provider-configs-${{ github.ref_name }}.tar.gz | ||
| ``` | ||
| --- | ||
| *This release was automatically generated from the latest provider data.* | ||
| files: | | ||
| dist/*.json | ||
| *.tar.gz | ||
| draft: false | ||
| prerelease: false | ||