Skip to content

Commit

Permalink
optimizing API call amount
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsupr committed Jun 13, 2024
1 parent e2601f3 commit 961d38e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/sync_upstream_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ jobs:
| jq -r '.[] | .name' | tr [:upper:] [:lower:] | sort > fork_branches.txt
echo $(grep -x -v -f upstream_branches.txt fork_branches.txt > branches_deleted_list.txt)
echo $MAIN_BRANCH > branches_synced_list.txt
echo $(grep -E "$BRANCHES_TO_SYNC_EGREP_REGEX" upstream_branches.txt | \
grep -v $MAIN_BRANCH >> branches_synced_list.txt)
grep -v $MAIN_BRANCH > branches_synced_list.txt)
echo $(grep -x -v -f fork_branches.txt branches_synced_list.txt > branches_created_list.txt)
echo $(grep -x -v -f branches_created_list.txt branches_synced_list.txt > upd_synced_list)
mv upd_synced_list branches_synced_list.txt
for f in branches_*_list.txt; do
ACTION=$(echo $f | cut -d '_' -f 2)
Expand All @@ -92,8 +93,9 @@ jobs:
echo "======"
echo ""
done
echo "Branch $MAIN_BRANCH to be synced always first and separately"
- name: Sync the Main/Master branch anyway first
- name: Sync the Main/Master branch always first and separately
id: sync_master_brach
env:
GH_TOKEN: ${{ steps.gen_app_token_merge.outputs.token }}
Expand Down Expand Up @@ -128,19 +130,19 @@ jobs:
run: |
cd /tmp
for BRANCH in $(cat branches_created_list.txt); do
COMMIT=$(gh api --method GET \
UPSTREAM_COMMIT=$(gh api --method GET \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$UPSTREAM_REPO/git/ref/heads/$BRANCH \
| jq -r '.object.sha')
echo -n "Creating $BRANCH pointing to commit $COMMIT... "
echo -n "Creating $BRANCH pointing to commit $UPSTREAM_COMMIT... "
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$FORKED_REPO/git/refs \
-f "ref=refs/heads/$BRANCH" \
-f "sha=$COMMIT" > /dev/null
-f "sha=$UPSTREAM_COMMIT" > /dev/null
echo "done"
done
Expand Down

0 comments on commit 961d38e

Please sign in to comment.