1- name : push pydantic library_generation to bkbit
1+ name : push pydantic models to bkbit
22
33on :
44 push :
55 branches :
66 - main
7- # paths: 'models_py-autogen/library_generation.py'
8- # workflow_run:
9- # workflows: [generating other formats]
10- # types:
11- # - completed
12-
7+ # paths:
8+ # - 'models_py-autogen/**'
139jobs :
14- create_bkbit_pr_library_generation :
15- runs-on : ubuntu-latest
10+ # ------------------------------------------------------------------------------------------------------------------------------------------------
11+ # Event `pull_request`: Compare the last commit of the main branch or last remote commit of the PR branch -> to the current commit of a PR branch.
12+ # ------------------------------------------------------------------------------------------------------------------------------------------------
13+
14+ changed_files :
15+ runs-on : ubuntu-latest # windows-latest || macos-latest
16+ name : Test changed-files
1617 steps :
17- - name : Checkout this repository
18- uses : actions/checkout@v3
18+ - uses : actions/checkout@v4
1919
2020 - name : Set up Git and cloning repository
2121 env :
@@ -26,24 +26,37 @@ jobs:
2626 git config --global user.email "[email protected] " 2727 git clone https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/$TARGET_REPO.git
2828
29- - name : Make changes to target repository
30- id : changes
31- run : |
32- # copy updated pydantic model from brain-bican/models to brain-bican/bkbit
33- cp models_py-autogen/library_generation.py bkbit/bkbit/models/library_generation.py
29+ - name : Get changed files in the models_py-autogen folder
30+ id : changed-files-specific
31+ uses : tj-actions/changed-files@v45
32+ with :
33+ files : models_py-autogen/**
34+
35+ - name : Run step if any file(s) in the models_py-autogen folder change
36+ if : steps.changed-files-specific.outputs.any_changed == 'true'
37+ env :
38+ ALL_CHANGED_FILES : ${{ steps.changed-files-specific.outputs.all_changed_files }}
39+ run : |
40+ echo "One or more files in the models_py-autogen folder has changed."
41+ echo "List all the files that have changed: $ALL_CHANGED_FILES"
42+ echo "$ALL_CHANGED_FILES" | tr ',' '\n' | while read -r FILE; do
43+ FILENAME=$(basename "$FILE")
44+ echo "Processing file: $FILENAME"
45+ cp $FILE bkbit/bkbit/models/$FILENAME
46+ done
3447 cd bkbit
35- git checkout -b update_library_generation_model
36- git add bkbit/models/library_generation.py
37- git commit -m "Updated version of library_generation model is being copied and pushed from brain-bican/models repository."
48+ git checkout -b new_version_of_model
49+ git add bkbit/models/*
50+ git commit -m "Updated model(s), ${ALL_CHANGED_FILES}, are being copied and pushed from brain-bican/models repository."
3851 cd ..
39-
52+
4053 - name : Push changes to bkbit
4154 env :
4255 TARGET_REPO : brain-bican/bkbit
4356 PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
4457 run : |
4558 cd bkbit
46- git push origin update_library_generation_model
59+ git push origin new_version_of_model
4760
4861 - name : Create pull request to bkbit
4962 env :
5265 run : |
5366 curl -X POST -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
5467 -d '{"title":"Automated PR: Add new version of the library_generation model.", "head":"update_library_generation_model", "base":"main"}' \
55- https://api.github.com/repos/$TARGET_REPO/pulls
68+ https://api.github.com/repos/$TARGET_REPO/pulls
0 commit comments