Update Gradle dependencies #144
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Gradle dependencies | |
| on: | |
| schedule: | |
| - cron: "0 4 * * 0" | |
| workflow_dispatch: | |
| jobs: | |
| update-gradle-dependencies: | |
| runs-on: ubuntu-latest | |
| name: Update Gradle dependencies | |
| permissions: | |
| contents: read | |
| id-token: write # Required for OIDC token federation | |
| steps: | |
| - uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 | |
| id: octo-sts | |
| with: | |
| scope: DataDog/dd-trace-java | |
| policy: self.update-gradle-dependencies.create-pr | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0 | |
| with: | |
| submodules: "recursive" | |
| - name: Update Gradle dependencies | |
| env: | |
| ORG_GRADLE_PROJECT_akkaRepositoryToken: ${{ secrets.AKKA_REPO_TOKEN }} | |
| run: | | |
| find . -name 'gradle.lockfile' -delete | |
| GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx3G -Xms2G'" \ | |
| JAVA_HOME=$JAVA_HOME_8_X64 \ | |
| JAVA_8_HOME=$JAVA_HOME_8_X64 \ | |
| JAVA_11_HOME=$JAVA_HOME_11_X64 \ | |
| JAVA_17_HOME=$JAVA_HOME_17_X64 \ | |
| JAVA_21_HOME=$JAVA_HOME_21_X64 \ | |
| JAVA_25_HOME=$JAVA_HOME_25_X64 \ | |
| ./gradlew resolveAndLockAll --write-locks --parallel --stacktrace --no-daemon --max-workers=4 | |
| - name: Check if changes should be committed | |
| id: check-changes | |
| run: | | |
| if [[ -z "$(git status -s)" ]]; then | |
| echo "No changes to commit, exiting." | |
| echo "commit_changes=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| else | |
| echo "commit_changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Pick a branch name | |
| if: steps.check-changes.outputs.commit_changes == 'true' | |
| id: define-branch | |
| run: echo "branch=ci/update-gradle-dependencies-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
| - name: Commit changes | |
| if: steps.check-changes.outputs.commit_changes == 'true' | |
| id: create-commit | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add --all | |
| git commit -m "chore: Update Gradle dependencies" | |
| echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
| - name: Push changes | |
| uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1 | |
| if: steps.check-changes.outputs.commit_changes == 'true' | |
| with: | |
| token: "${{ steps.octo-sts.outputs.token }}" | |
| branch: "${{ steps.define-branch.outputs.branch }}" | |
| # for scheduled runs, sha is the tip of the default branch | |
| # for dispatched runs, sha is the tip of the branch it was dispatched on | |
| head-sha: "${{ github.sha }}" | |
| create-branch: true | |
| command: push | |
| commits: "${{ steps.create-commit.outputs.commit }}" | |
| - name: Create pull request | |
| if: steps.check-changes.outputs.commit_changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ steps.octo-sts.outputs.token }} | |
| run: | | |
| # use echo to set a multiline body for the PR | |
| 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" | \ | |
| gh pr create --title "Update Gradle dependencies" \ | |
| --base master \ | |
| --head ${{ steps.define-branch.outputs.branch }} \ | |
| --label "tag: dependencies" \ | |
| --label "tag: no release notes" \ | |
| --body-file - |