Skip to content

Updated runner.py

Updated runner.py #9

name: Extract OpenAI Types
on:
push:
branches:
- master
workflow_dispatch:
jobs:
extract-types:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
- name: Download latest OpenAI release zip
run: |
latest_release=$(curl -s https://api.github.com/repos/openai/openai-python/releases/latest | jq -r '.tag_name')
curl -L "https://github.com/openai/openai-python/archive/refs/tags/${latest_release}.zip" -o openai-latest.zip
echo "Downloaded OpenAI release: ${latest_release}"
- name: Extract `types` folder
run: |
unzip openai-latest.zip -d openai-package
echo "Contents of openai-package:"
ls -R openai-package
mkdir -p temp_types
cp -r openai-package/openai-python-*/src/openai/types/* temp_types/
echo "Contents of temp_types:"
ls -R temp_types
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
echo "Current directory contents:"
ls -la
# Fetch all branches
git fetch --all
# Remove untracked files
git clean -fd
# Check if the branch exists
if git ls-remote --exit-code --heads origin openai-types-extracted; then
# If it exists, check it out and reset to the remote version
git checkout openai-types-extracted
git reset --hard origin/openai-types-extracted
else
# If it doesn't exist, create a new branch
git checkout -b openai-types-extracted
fi
echo "Contents after checkout:"
ls -la
# Remove existing types directory if it exists
rm -rf lmos_openai_types/types
# Ensure lmos_openai_types directory exists
mkdir -p lmos_openai_types
# Move the new types into place
mv temp_types lmos_openai_types/types
echo "Final directory structure:"
ls -R lmos_openai_types
# Add all changes
git add .
# Check if there are any changes
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
fi
# Commit the changes
git commit -m "Extracted types from OpenAI ${latest_release}"
# Force push the changes
git push -f origin openai-types-extracted