Opens a new PR if there are model updates #16
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: Opens a new PR if there are model updates | |
on: | |
schedule: | |
- cron: '30 6 * * 1' | |
permissions: | |
contents: write | |
pull-requests: write | |
actions: write | |
jobs: | |
deep-infra: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Git user | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "github-actions[bot]" | |
- name: Generate branch name | |
id: branch | |
run: echo "branch_name=bot/update-deep-infra_$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT | |
- name: Create branch | |
run: | | |
git checkout -b ${{ steps.branch.outputs.branch_name }} origin/main | |
git rebase main | |
- name: Install .NET SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Generate code | |
run: | | |
cd src/DeepInfra/tools/LangChain.Providers.DeepInfra.CodeGenerator | |
dotnet run --output ../../src | |
- name: Format code | |
run: | | |
dotnet format | |
dotnet format analyzers --diagnostics=RS0016 | |
- name: Check for changes | |
id: changes | |
run: | | |
CHANGED=$(git diff --name-only) | |
if [ -z "$CHANGED" ]; then | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Push changes | |
if: steps.changes.outputs.has_changes == 'true' | |
run: | | |
git add . | |
git commit -m "feat: Updated Deep Infra models" | |
git push --force-with-lease -u origin ${{ steps.branch.outputs.branch_name }} | |
- name: Wait for 15 seconds | |
if: steps.changes.outputs.has_changes == 'true' | |
run: sleep 15 | |
- name: Create pull request | |
if: steps.changes.outputs.has_changes == 'true' | |
run: gh pr create -B main -H ${{ steps.branch.outputs.branch_name }} --title 'feat:Updated Deep Infra models' --body 'Created by Github Actions' | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} |