99 runs-on : ubuntu-latest
1010 name : Update Gradle dependencies
1111 permissions :
12- contents : write # Required to create new branch
12+ contents : read
1313 id-token : write # Required for OIDC token federation
1414 steps :
1515 - uses : DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
@@ -22,16 +22,20 @@ jobs:
2222 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
2323 with :
2424 submodules : " recursive"
25- - name : Download ghcommit CLI
25+ - name : Configure git
26+ id : configure-git
2627 run : |
27- curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
28- chmod +x /usr/local/bin/ghcommit
28+ git config user.name "github-actions[bot]"
29+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
2930 - name : Pick a branch name
30- run : echo "BRANCH_NAME=ci/update-gradle-dependencies-$(date +'%Y%m%d')" >> $GITHUB_ENV
31+ id : define-branch
32+ run : echo "branch=ci/update-gradle-dependencies-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
3133 - name : Create branch
3234 run : |
33- git checkout -b $BRANCH_NAME
34- git push -u origin $BRANCH_NAME --force
35+ git checkout -b ${{ steps.define-branch.outputs.branch }} --force
36+ git push -u origin ${{ steps.define-branch.outputs.branch }} --force
37+ env :
38+ GITHUB_TOKEN : ${{ steps.octo-sts.outputs.token }}
3539 - name : Update Gradle dependencies
3640 run : |
3741 GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx3G -Xms2G'" \
@@ -42,46 +46,29 @@ jobs:
4246 JAVA_21_HOME=$JAVA_HOME_21_X64 \
4347 ./gradlew resolveAndLockAll --write-locks --parallel --stacktrace --no-daemon --max-workers=4
4448 - name : Commit changes
49+ id : create-commit
50+ run : |
51+ git add .
52+ git commit --message "chore: Update Gradle dependencies"
53+ echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
4554 env :
4655 GITHUB_TOKEN : ${{ steps.octo-sts.outputs.token }}
47- run : |
48- GH_ADD_ARGS=""
49- COUNT=0
50- BRANCH_HEAD=$(git rev-parse HEAD)
51- for lockfile in $(git status --porcelain=v1 | awk '{ print $NF }'); do
52- echo "Found lockfile: $lockfile"
53- GH_ADD_ARGS="$GH_ADD_ARGS --add $lockfile"
54- COUNT=$((COUNT+1))
55- if [ $COUNT -eq 10 ]; then
56- echo "Creating a commit to $BRANCH_NAME@$BRANCH_HEAD with $GH_ADD_ARGS"
57- OUTPUT=$(ghcommit --repository ${{ github.repository }} --branch $BRANCH_NAME --sha $BRANCH_HEAD $GH_ADD_ARGS --message "chore: Update Gradle dependencies" 2>&1)
58- echo $OUTPUT
59- if [[ $OUTPUT != *"Success. New commit"* ]]; then
60- exit 1
61- fi
62- BRANCH_HEAD=${OUTPUT##*/}
63- echo "ghcommit output: $OUTPUT"
64- GH_ADD_ARGS=""
65- COUNT=0
66- fi
67- done
68- # Check at uncommited files
69- echo "Checking uncommited files"
70- git status
71- # Create a PR from the created branch
72- if [ $COUNT -gt 0 ]; then
73- echo "Creating a commit to $BRANCH_NAME@$BRANCH_HEAD with $GH_ADD_ARGS"
74- ghcommit --repository ${{ github.repository }} --branch $BRANCH_NAME --sha $BRANCH_HEAD $GH_ADD_ARGS --message "chore: Update Gradle dependencies"
75- fi
56+ - name : Push changes
57+ uses : Asana/push-signed-commits@d615ca88d8e1a946734c24970d1e7a6c56f34897
58+ if : ${{ steps.create-commit.outputs.commit != '' }}
59+ with :
60+ github-token : ${{ steps.octo-sts.outputs.token }}
61+ local_branch_name : ${{ steps.define-branch.outputs.branch }}
62+ remote_branch_name : ${{ steps.define-branch.outputs.branch }}
7663 - name : Create pull request
77- env :
78- GH_TOKEN : ${{ steps.octo-sts.outputs.token }}
7964 run : |
8065 # use echo to set a multiline body for the PR
81- 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" | \
66+ 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" | \
8267 gh pr create --title "Update Gradle dependencies" \
8368 --base master \
84- --head $BRANCH_NAME \
69+ --head ${{ steps.define-branch.outputs.branch }} \
8570 --label "tag: dependencies" \
8671 --label "tag: no release notes" \
8772 --body-file -
73+ env :
74+ GITHUB_TOKEN : ${{ steps.octo-sts.outputs.token }}
0 commit comments