Skip to content

Commit 7232c82

Browse files
authored
Update GHA workflows to use commit-headless (#9702)
* Update jmxfetch workflow * Update cloudfoundry workflow * Update docker workflow * Update gradle workflow * Empty commit to re-run benchmarks
1 parent 24adc9a commit 7232c82

File tree

4 files changed

+85
-73
lines changed

4 files changed

+85
-73
lines changed

.github/workflows/add-release-to-cloudfoundry.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,23 @@ jobs:
4242
- name: Append release to Cloud Foundry repository
4343
run: |
4444
echo "${{ steps.get-release-version.outputs.VERSION }}: ${{ steps.get-release-url.outputs.URL }}" >> index.yml
45-
- name: Commit and push changes
46-
uses: planetscale/ghcommit-action@f24050e41f8694750427d111b52f4ef9ca81a32d # v0.2.18
45+
- name: Commit changes
46+
id: create-commit
47+
run: |
48+
git config user.name "github-actions[bot]"
49+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
50+
51+
if [[ -z "$(git status -s)" ]]; then
52+
echo "No changes to commit, exiting."
53+
exit 0;
54+
fi
55+
56+
git commit -a -m "chore: Add version ${{ steps.get-release-version.outputs.VERSION }} to Cloud Foundry"
57+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
58+
- name: Push changes
59+
uses: DataDog/commit-headless@1186485b788f57eedaaadb19919781698b4d262f # action/v1.0.0
60+
if: ${{ steps.create-commit.outputs.commit != '' }}
4761
with:
48-
commit_message: "chore: Add version ${{ steps.get-release-version.outputs.VERSION }} to Cloud Foundry"
49-
repo: ${{ github.repository }}
5062
branch: cloudfoundry
51-
env:
52-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
63+
command: push
64+
commits: "${{ steps.create-commit.outputs.commit }}"

.github/workflows/update-docker-build-image.yaml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
update-docker-build-image:
1616
runs-on: ubuntu-latest
1717
permissions:
18-
contents: write # Required to create and push branch
18+
contents: read
1919
id-token: write # Required for OIDC token federation
2020
steps:
2121
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
@@ -58,26 +58,29 @@ jobs:
5858
else
5959
echo "commit_changes=true" >> "$GITHUB_OUTPUT"
6060
fi
61-
- name: Download ghcommit CLI
62-
if: steps.check-changes.outputs.commit_changes == 'true'
63-
run: |
64-
curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
65-
chmod +x /usr/local/bin/ghcommit
6661
- name: Pick a branch name
6762
if: steps.check-changes.outputs.commit_changes == 'true'
6863
id: define-branch
6964
run: echo "branch=ci/update-docker-build-image-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
70-
- name: Create branch
65+
- name: Commit changes
7166
if: steps.check-changes.outputs.commit_changes == 'true'
67+
id: create-commit
7268
run: |
73-
git checkout -b ${{ steps.define-branch.outputs.branch }}
74-
git push -u origin ${{ steps.define-branch.outputs.branch }} --force
75-
- name: Commit and push changes
69+
git config user.name "github-actions[bot]"
70+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
71+
git commit -m "feat(ci): Update Docker build image" .gitlab-ci.yml
72+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
73+
- name: Push changes
74+
uses: DataDog/commit-headless@1186485b788f57eedaaadb19919781698b4d262f # action/v1.0.0
7675
if: steps.check-changes.outputs.commit_changes == 'true'
77-
env:
78-
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
79-
run: |
80-
ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add .gitlab-ci.yml --message "feat(ci): Update Docker build image"
76+
with:
77+
token: "${{ steps.octo-sts.outputs.token }}"
78+
branch: "${{ steps.define-branch.outputs.branch }}"
79+
# for scheduled runs, sha is the tip of the default branch
80+
# for dispatched runs, sha is the tip of the branch it was dispatched on
81+
branch-from: "${{ github.sha }}"
82+
command: push
83+
commits: "${{ steps.create-commit.outputs.commit }}"
8184
- name: Create pull request
8285
if: steps.check-changes.outputs.commit_changes == 'true'
8386
env:

.github/workflows/update-gradle-dependencies.yaml

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
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,6 @@ jobs:
2222
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
2323
with:
2424
submodules: "recursive"
25-
- name: Download ghcommit CLI
26-
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
29-
- name: Pick a branch name
30-
run: echo "BRANCH_NAME=ci/update-gradle-dependencies-$(date +'%Y%m%d')" >> $GITHUB_ENV
31-
- name: Create branch
32-
run: |
33-
git checkout -b $BRANCH_NAME
34-
git push -u origin $BRANCH_NAME --force
3525
- name: Update Gradle dependencies
3626
env:
3727
ORG_GRADLE_PROJECT_akkaRepositoryToken: ${{ secrets.AKKA_REPO_TOKEN }}
@@ -42,40 +32,43 @@ jobs:
4232
JAVA_11_HOME=$JAVA_HOME_11_X64 \
4333
JAVA_17_HOME=$JAVA_HOME_17_X64 \
4434
JAVA_21_HOME=$JAVA_HOME_21_X64 \
35+
JAVA_25_HOME=$JAVA_HOME_25_X64 \
4536
./gradlew resolveAndLockAll --write-locks --parallel --stacktrace --no-daemon --max-workers=4
46-
- name: Commit changes
47-
env:
48-
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
37+
- name: Check if changes should be committed
38+
id: check-changes
4939
run: |
50-
GH_ADD_ARGS=""
51-
COUNT=0
52-
BRANCH_HEAD=$(git rev-parse HEAD)
53-
for lockfile in $(git status --porcelain=v1 -- ':(glob)**/gradle.lockfile' | awk '{ print $NF }'); do
54-
echo "Found lockfile: $lockfile"
55-
GH_ADD_ARGS="$GH_ADD_ARGS --add $lockfile"
56-
COUNT=$((COUNT+1))
57-
if [ $COUNT -eq 10 ]; then
58-
echo "Creating a commit to $BRANCH_NAME@$BRANCH_HEAD with $GH_ADD_ARGS"
59-
OUTPUT=$(ghcommit --repository ${{ github.repository }} --branch $BRANCH_NAME --sha $BRANCH_HEAD $GH_ADD_ARGS --message "chore: Update Gradle dependencies" 2>&1)
60-
echo $OUTPUT
61-
if [[ $OUTPUT != *"Success. New commit"* ]]; then
62-
exit 1
63-
fi
64-
BRANCH_HEAD=${OUTPUT##*/}
65-
echo "ghcommit output: $OUTPUT"
66-
GH_ADD_ARGS=""
67-
COUNT=0
68-
fi
69-
done
70-
# Check at uncommited files
71-
echo "Checking uncommited files"
72-
git status
73-
# Create a PR from the created branch
74-
if [ $COUNT -gt 0 ]; then
75-
echo "Creating a commit to $BRANCH_NAME@$BRANCH_HEAD with $GH_ADD_ARGS"
76-
ghcommit --repository ${{ github.repository }} --branch $BRANCH_NAME --sha $BRANCH_HEAD $GH_ADD_ARGS --message "chore: Update Gradle dependencies"
40+
if [[ -z "$(git status -s)" ]]; then
41+
echo "No changes to commit, exiting."
42+
echo "commit_changes=false" >> "$GITHUB_OUTPUT"
43+
exit 0
44+
else
45+
echo "commit_changes=true" >> "$GITHUB_OUTPUT"
7746
fi
47+
- name: Pick a branch name
48+
if: steps.check-changes.outputs.commit_changes == 'true'
49+
id: define-branch
50+
run: echo "BRANCH_NAME=ci/update-gradle-dependencies-$(date +'%Y%m%d')" >> $GITHUB_ENV
51+
- name: Commit changes
52+
if: steps.check-changes.outputs.commit_changes == 'true'
53+
id: create-commit
54+
run: |
55+
git config user.name "github-actions[bot]"
56+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
57+
git commit -a -m "chore: Update Gradle dependencies"
58+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
59+
- name: Push changes
60+
uses: DataDog/commit-headless@1186485b788f57eedaaadb19919781698b4d262f # action/v1.0.0
61+
if: steps.check-changes.outputs.commit_changes == 'true'
62+
with:
63+
token: "${{ steps.octo-sts.outputs.token }}"
64+
branch: "${{ steps.define-branch.outputs.branch }}"
65+
# for scheduled runs, sha is the tip of the default branch
66+
# for dispatched runs, sha is the tip of the branch it was dispatched on
67+
branch-from: "${{ github.sha }}"
68+
command: push
69+
commits: "${{ steps.create-commit.outputs.commit }}"
7870
- name: Create pull request
71+
if: steps.check-changes.outputs.commit_changes == 'true'
7972
env:
8073
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
8174
run: |

.github/workflows/update-jmxfetch-submodule.yaml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: write # Required to create and push 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
@@ -38,21 +38,25 @@ jobs:
3838
if: steps.check-changes.outputs.commit_changes == 'true'
3939
id: define-branch
4040
run: echo "branch=ci/update-jmxfetch-submodule-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
41-
- name: Create branch
41+
- name: Commit changes
4242
if: steps.check-changes.outputs.commit_changes == 'true'
43-
run: |
44-
git checkout -b ${{ steps.define-branch.outputs.branch }}
45-
git push -u origin ${{ steps.define-branch.outputs.branch }} --force
46-
- name: Commit and push changes
47-
if: steps.check-changes.outputs.commit_changes == 'true'
48-
env:
49-
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
43+
id: create-commit
5044
run: |
5145
git config user.name "github-actions[bot]"
5246
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53-
git add dd-java-agent/agent-jmxfetch/integrations-core
54-
git commit -m "Update agent-jmxfetch submodule"
55-
git push origin ${{ steps.define-branch.outputs.branch }}
47+
git commit -m "feat(ci): Update agent-jmxfetch submodule" dd-java-agent/agent-jmxfetch/integrations-core
48+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
49+
- name: Push changes
50+
uses: DataDog/commit-headless@1186485b788f57eedaaadb19919781698b4d262f # action/v1.0.0
51+
if: steps.check-changes.outputs.commit_changes == 'true'
52+
with:
53+
token: "${{ steps.octo-sts.outputs.token }}"
54+
branch: "${{ steps.define-branch.outputs.branch }}"
55+
# for scheduled runs, sha is the tip of the default branch
56+
# for dispatched runs, sha is the tip of the branch it was dispatched on
57+
branch-from: "${{ github.sha }}"
58+
command: push
59+
commits: "${{ steps.create-commit.outputs.commit }}"
5660
- name: Create pull request
5761
if: steps.check-changes.outputs.commit_changes == 'true'
5862
env:

0 commit comments

Comments
 (0)