Scrape OpenAI data #269
This file contains 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: Scrape OpenAI data | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
- cron: '1 2 * * *' | |
permissions: | |
contents: write | |
jobs: | |
ai-scraper: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Scrape | |
run: | | |
export FILEPATH="openai/api/models.txt" | |
curl https://api.openai.com/v1/models -H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" | jq -r '.data | .[] | .id' | sort -n > ${FILEPATH} | |
- name: Commit and push | |
run: |- | |
git config user.name "Automated" | |
git config user.email "[email protected]" | |
git add -A | |
timestamp=$(date -u) | |
git commit -m "${timestamp}" || exit 0 | |
git pull --rebase | |
git push |