Skip to content

Commit

Permalink
Update update-submodules.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj authored Aug 13, 2024
1 parent 123baa5 commit 0ee28b7
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/update-submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,46 @@ jobs:
- name: Update submodules to latest release
run: |
cd ThirdParty
submodules=("fast_float" "qtadvanceddocking" "regression-analysis" "roff-cpp" "spdlog" "tomlplusplus" )
submodules=("fast_float" "spdlog" "tomlplusplus" )
for submodule in "${submodules[@]}"; do
BRANCH_NAME=ci-update-$submodule
if git show-ref --verify --quiet refs/heads/$BRANCH_NAME; then
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME exists."
git checkout $BRANCH_NAME
git checkout -b "$BRANCH_NAME" "origin/$BRANCH_NAME"
else
echo "Branch $BRANCH_NAME does not exist. Creating branch."
git checkout -b $BRANCH_NAME
git checkout -b "$BRANCH_NAME"
fi
cd $submodule
git fetch --tags
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latest_tag
if [ -n "$latest_tag" ]; then
git checkout $latest_tag
else
echo "Empty tag detected in $submodule. Nothing to do."
fi
cd ..
git add $submodule
git commit -m "Update $submodule to $latest_tag" || echo "No changes to commit"
git push origin $BRANCH_NAME
if git diff --quiet; then
echo "No changes detected in $submodule"
else
git add $submodule
git commit -m "Update $submodule to $latest_tag" || echo "No changes to commit"
git push origin "$BRANCH_NAME"
fi
git checkout dev
git reset --hard origin/dev --recurse-submodule
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Pull Requests for each submodule
run: |
submodules=("fast_float" "qtadvanceddocking" "regression-analysis" "roff-cpp" "spdlog" "tomlplusplus" )
submodules=("fast_float" "spdlog" "tomlplusplus" )
for submodule in "${submodules[@]}"; do
gh pr create --title "Update $submodule to latest release" --body "This PR updates the $submodule submodule to its latest release." --head ci-update-$submodule --base dev
done
Expand Down

0 comments on commit 0ee28b7

Please sign in to comment.