Skip to content

Commit

Permalink
Update update-submodules.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
czyt authored Apr 18, 2024
1 parent e6f71e2 commit eec3193
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/update-submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,24 @@ jobs:
- name: Update Submodules
run: |
echo "update submodule"
echo "Update submodule"
git submodule update --remote --recursive
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
echo "check submodule is changed or not"
# Check if submodules have changed
SUBMODULES_CHANGED=$(git submodule foreach --recursive 'git ls-files -m | grep . && echo "changed" || :')
if [ "x$SUBMODULES_CHANGED" != "x" ]; then
echo "submodule is changed ,create new branch"
# Create a new branch
echo "Check if submodule is changed or not"
# Track submodule changes
git status
git diff --submodule
git add .

# Conditional commit and push if there are changes
if git diff --cached ; then
echo "Submodule is changed, create new branch"
git checkout -b update-submodules-${{ github.run_id }}
echo "commit change to the new branch"
git commit -am "Automatically update submodules"
# Push the branch and create a pull request
echo "push the new branch update-submodules-${{ github.run_id }}"
git commit -m "Automatically update submodules"
echo "Push the new branch update-submodules-${{ github.run_id }}"
git push --set-upstream origin update-submodules-${{ github.run_id }}
echo "create a PR"
echo "Create a PR"
gh pr create --title "Auto-update submodules" --body "Automated changes to update submodules" --head update-submodules-${{ github.run_id }} --base main
else
echo "No changes in submodules."
echo "No changes in submodules to commit."
fi

0 comments on commit eec3193

Please sign in to comment.