2323 with :
2424 submodules : " recursive"
2525 - name : Pick a branch name
26+ id : define-branch
2627 run : echo "branch=ci/update-gradle-dependencies-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
2728 - name : Update Gradle dependencies
2829 run : |
@@ -33,62 +34,44 @@ jobs:
3334 JAVA_17_HOME=$JAVA_HOME_17_X64 \
3435 JAVA_21_HOME=$JAVA_HOME_21_X64 \
3536 ./gradlew resolveAndLockAll --write-locks --parallel --stacktrace --no-daemon --max-workers=4
37+ - name : Check for changes
38+ id : check-changes
39+ run : |
40+ if [[ -z "$(git status -s)" ]]; then
41+ echo "No changes to commit, exiting."
42+ echo "has_changes=false" >> "$GITHUB_OUTPUT"
43+ exit 0
44+ else
45+ echo "has_changes=true" >> "$GITHUB_OUTPUT"
46+ fi
3647 - name : Commit changes
37- id : create-commits
38- env :
39- BRANCH_NAME : ${{ steps.define-branch.outputs.branch }}
48+ if : steps.check-changes.outputs.has_changes == 'true'
49+ id : create-commit
4050 run : |
4151 git config user.name "github-actions[bot]"
4252 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
43-
44- FILES=""
45- COMMITS=""
46- COUNT=0
47- # XXX: Could be replaced by ${{ github.sha }}
48- BRANCH_HEAD=$(git rev-parse HEAD)
49- for lockfile in $(git status --porcelain=v1 | awk '{ print $NF }'); do
50- echo "Found lockfile: $lockfile"
51- FILES="$FILES $lockfile"
52- COUNT=$((COUNT+1))
53- if [ $COUNT -eq 10 ]; then
54- echo "Creating a commit to $BRANCH_NAME@$BRANCH_HEAD with files $FILES"
55- git commit --no-verify --message="chore: Update Gradle dependencies" "${FILES}"
56- COMMITS="$COMMITS $(git rev-parse HEAD)"
57- FILES=""
58- COUNT=0
59- fi
60- done
61- # Check at uncommited files
62- echo "Checking uncommited files"
63- git status
64-
65- # Commit any remaining files
66- if [ $COUNT -gt 0 ]; then
67- echo "Creating a commit to $BRANCH_NAME@$BRANCH_HEAD with $FILES"
68- git commit --no-verify --message="chore: Update Gradle dependencies" "${FILES}"
69- COMMITS="$COMMITS $(git rev-parse HEAD)"
70- fi
71-
72- echo "Commits to push: ${COMMITS}"
73- echo "commits=\"${COMMITS}\"" >> $GITHUB_OUTPUT
53+ git add .
54+ git commit --no-verify --message="chore: Update Gradle dependencies"
55+ echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
7456 - name : Push changes
7557 uses : DataDog/commit-headless@1186485b788f57eedaaadb19919781698b4d262f # action/v1.0.0
76- if : ${{ steps.create-commits .outputs.commits != '' }}
58+ if : ${{ steps.check-changes.outputs.has_changes == 'true' && steps. create-commit .outputs.commit != '' }}
7759 with :
7860 token : " ${{ steps.octo-sts.outputs.token }}"
7961 branch : " ${{ steps.define-branch.outputs.branch }}"
8062 # for scheduled runs, sha is the tip of the default branch
8163 # for dispatched runs, sha is the tip of the branch it was dispatched on
8264 branch-from : " ${{ github.sha }}"
8365 command : push
84- commits : " ${{ steps.create-commits .outputs.commits }}"
66+ commits : " ${{ steps.create-commit .outputs.commit }}"
8567 - name : Create pull request
68+ if : steps.check-changes.outputs.has_changes == 'true'
8669 env :
8770 GH_TOKEN : ${{ steps.octo-sts.outputs.token }}
8871 BRANCH_NAME : ${{ steps.define-branch.outputs.branch }}
8972 run : |
9073 # use echo to set a multiline body for the PR
91- echo -e "This PR updates the Gradle dependencies. ⚠️ Don't forget to squash commits before merging. ⚠️ \n\n- [ ] Update PR title if a code change is needed to support one of those new dependencies" | \
74+ echo -e "This PR updates the Gradle dependencies.\n\n- [ ] Update PR title if a code change is needed to support one of those new dependencies" | \
9275 gh pr create --title "Update Gradle dependencies" \
9376 --base master \
9477 --head $BRANCH_NAME \
0 commit comments