Skip to content

Commit a84829f

Browse files
committed
refactor: remove daily schedule and implement PR-based updates
- Remove daily schedule trigger from GitHub Actions - Implement automatic PR creation for manual/dispatch triggers - Add direct commit for code push events (to avoid infinite loops) - Update workflow permissions for PR creation - Simplify release logic to only handle tagged releases - Update documentation to explain new PR-based update mechanism
1 parent 556d339 commit a84829f

File tree

2 files changed

+83
-65
lines changed

2 files changed

+83
-65
lines changed

β€Ž.github/workflows/fetch-models.ymlβ€Ž

Lines changed: 74 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Fetch AI Models
22

33
on:
4-
schedule:
5-
# Run daily at 06:00 UTC
6-
- cron: '0 6 * * *'
74
workflow_dispatch:
85
inputs:
96
providers:
@@ -26,6 +23,9 @@ env:
2623
jobs:
2724
fetch-and-update:
2825
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
pull-requests: write
2929

3030
steps:
3131
- name: Checkout repository
@@ -102,8 +102,67 @@ jobs:
102102
echo "timestamp=$(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
103103
echo "date_short=$(date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
104104
105-
- name: Commit and push updates
106-
if: github.ref_type != 'tag'
105+
- name: Create Pull Request with updates
106+
if: github.ref_type != 'tag' && github.event_name != 'push'
107+
run: |
108+
git config --local user.email "action@github.com"
109+
git config --local user.name "GitHub Action"
110+
111+
# Copy generated files to provider_configs for direct access
112+
cp -r dist/* provider_configs/ || true
113+
114+
# Check if there are changes
115+
git add provider_configs/
116+
if ! git diff --staged --quiet; then
117+
# Create a new branch for the PR
118+
BRANCH_NAME="update-models-$(date -u +%Y%m%d-%H%M%S)"
119+
git checkout -b "$BRANCH_NAME"
120+
121+
# Commit changes
122+
git commit -m "πŸ€– Update model configurations - $(date -u +%Y-%m-%d)"
123+
124+
# Push to remote
125+
git push origin "$BRANCH_NAME"
126+
127+
# Create PR using GitHub CLI
128+
gh pr create \
129+
--title "πŸ€– Update AI Model Configurations" \
130+
--body "$(cat <<'EOF'
131+
## πŸ€– Automated Model Configuration Update
132+
133+
**Generated:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
134+
**Total Models:** ${{ steps.release_info.outputs.total_models }}
135+
**Providers:** ${{ steps.release_info.outputs.provider_count }} (${{ steps.release_info.outputs.providers }})
136+
137+
### πŸ“‹ Changes
138+
- Updated model configurations from provider APIs
139+
- Refreshed capability detection (vision, function calling, reasoning)
140+
- Generated standardized JSON format files
141+
142+
### πŸ” Files Updated
143+
- `provider_configs/*.json` - Individual provider configurations
144+
- `provider_configs/all.json` - Aggregated model data
145+
146+
### βœ… Validation
147+
- [x] JSON syntax validation passed
148+
- [x] Model data structure validation passed
149+
- [x] Provider capability detection completed
150+
151+
---
152+
153+
*This PR was automatically created by GitHub Actions.*
154+
EOF
155+
)" \
156+
--head "$BRANCH_NAME" \
157+
--base main
158+
else
159+
echo "No changes to commit"
160+
fi
161+
env:
162+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
164+
- name: Direct commit (for push events)
165+
if: github.ref_type != 'tag' && github.event_name == 'push'
107166
run: |
108167
git config --local user.email "action@github.com"
109168
git config --local user.name "GitHub Action"
@@ -120,24 +179,19 @@ jobs:
120179
fi
121180
122181
- name: Create Release Assets
182+
if: github.ref_type == 'tag'
123183
run: |
124184
# Create tarball of all JSON files with proper naming
125185
cd dist
126-
if [ "${{ github.ref_type }}" = "tag" ]; then
127-
# For tag releases, use the tag name
128-
TAG_NAME="${{ github.ref_name }}"
129-
tar -czf "../provider-configs-${TAG_NAME}.tar.gz" *.json
130-
# Also create individual provider archives
131-
for file in *.json; do
132-
if [ "$file" != "all.json" ]; then
133-
provider_name=$(basename "$file" .json)
134-
tar -czf "../${provider_name}-${TAG_NAME}.tar.gz" "$file"
135-
fi
136-
done
137-
else
138-
# For scheduled/manual runs, use date
139-
tar -czf "../provider-configs-${{ steps.release_info.outputs.date_short }}.tar.gz" *.json
140-
fi
186+
TAG_NAME="${{ github.ref_name }}"
187+
tar -czf "../provider-configs-${TAG_NAME}.tar.gz" *.json
188+
# Also create individual provider archives
189+
for file in *.json; do
190+
if [ "$file" != "all.json" ]; then
191+
provider_name=$(basename "$file" .json)
192+
tar -czf "../${provider_name}-${TAG_NAME}.tar.gz" "$file"
193+
fi
194+
done
141195
cd ..
142196
143197
- name: Upload Artifacts (non-tag)
@@ -147,42 +201,8 @@ jobs:
147201
name: provider-configs-${{ steps.release_info.outputs.date_short }}
148202
path: |
149203
dist/*.json
150-
provider-configs-*.tar.gz
151204
retention-days: 30
152205

153-
- name: Create Release (scheduled)
154-
if: github.event_name == 'schedule'
155-
uses: softprops/action-gh-release@v1
156-
with:
157-
tag_name: auto-${{ steps.release_info.outputs.date_short }}
158-
name: Daily Auto Release ${{ steps.release_info.outputs.date_short }}
159-
body: |
160-
πŸ€– **Automated Daily Release of AI Model Configurations**
161-
162-
**Generated:** ${{ steps.release_info.outputs.timestamp }}
163-
**Total Models:** ${{ steps.release_info.outputs.total_models }}
164-
**Providers:** ${{ steps.release_info.outputs.provider_count }} (${{ steps.release_info.outputs.providers }})
165-
166-
## πŸ“¦ What's Included
167-
168-
This release contains the latest model information from all configured providers:
169-
- `provider-configs-${{ steps.release_info.outputs.date_short }}.tar.gz` - Complete package with all provider data
170-
- Individual JSON files for each provider
171-
- Aggregated JSON with all models combined
172-
173-
## πŸ”„ How to Use
174-
175-
Download and extract the files to access standardized AI model configurations for your applications.
176-
177-
```bash
178-
# Download and extract
179-
wget https://github.com/${{ github.repository }}/releases/download/auto-${{ steps.release_info.outputs.date_short }}/provider-configs-${{ steps.release_info.outputs.date_short }}.tar.gz
180-
tar -xzf provider-configs-${{ steps.release_info.outputs.date_short }}.tar.gz
181-
```
182-
files: provider-configs-*.tar.gz
183-
draft: false
184-
prerelease: false
185-
186206
- name: Create Release (tagged)
187207
if: github.ref_type == 'tag'
188208
uses: softprops/action-gh-release@v1

β€ŽREADME.mdβ€Ž

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,19 @@ export OPENROUTER_API_KEY="your-key-here"
143143
The project includes GitHub Actions workflow with multiple trigger methods:
144144

145145
### πŸ•°οΈ Automated Triggers
146-
- **Daily Schedule**: Runs automatically at UTC 06:00
147-
- **Code Changes**: Triggers on pushes to main branch (src/**, Cargo.toml, workflow file)
146+
- **Code Changes**: Triggers on pushes to main branch (src/**, Cargo.toml, workflow file) - Direct commit to main
148147
- **Release Tags**: Automatically triggered by `release-*.*.*` tags
149148

150149
### πŸ–±οΈ Manual Triggers
151-
- **Workflow Dispatch**: Manual trigger with optional provider selection
150+
- **Workflow Dispatch**: Manual trigger with optional provider selection - Creates PR for review
152151
- **Tag Release**: Create and push a `release-x.y.z` tag for versioned releases
153152

154-
### πŸ“¦ Release Types
153+
### πŸ”„ Update Mechanism
154+
- **Manual/Workflow Dispatch**: Creates a Pull Request for review and manual merge
155+
- **Code Push Events**: Direct commit to main branch (to avoid infinite loops)
156+
- **Tag Events**: No commits, only creates releases
155157

156-
#### Daily Auto Releases
157-
```bash
158-
# Automatic daily releases with date-based tags
159-
git tag auto-20250130 # Created automatically
160-
```
158+
### πŸ“¦ Release Types
161159

162160
#### Versioned Releases
163161
```bash
@@ -173,11 +171,11 @@ git push origin release-1.0.0
173171
```
174172

175173
### πŸ“„ Release Content
176-
Each release includes:
174+
Each tagged release includes:
177175
- πŸ“Š **Total model count** and **provider statistics**
178176
- πŸ• **Generation timestamp**
179177
- πŸ“¦ **Complete package** (`provider-configs-{version}.tar.gz`)
180-
- πŸ”— **Individual provider archives** (for tagged releases)
178+
- πŸ”— **Individual provider archives**
181179
- πŸ“‹ **Direct JSON file access**
182180
- πŸ’» **Integration examples**
183181

0 commit comments

Comments
Β (0)