force push #4
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: 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 | |
- name: Extract `types` folder | |
run: | | |
unzip openai-latest.zip -d openai-package | |
mkdir -p lmos-openai-types | |
cp -r openai-package/openai-python-*/src/openai/types lmos-openai-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" | |
# Fetch all branches | |
git fetch --all | |
# 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 | |
# Copy the new files | |
cp -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 |