Skip to content

Commit 4fed081

Browse files
authored
Fix jmxfetch workflow (#9306)
* Add write permissions and remove branch creation * Re-add step to create branch * Change commit and push logic * Add PR permissions * Use dd-octo-sts tokens * Remove ghcommit entirely
1 parent c614036 commit 4fed081

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # Required to create and push branch
13+
id-token: write # Required for OIDC token federation
1114
steps:
15+
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
16+
id: octo-sts
17+
with:
18+
scope: DataDog/dd-trace-java
19+
policy: self.update-jmxfetch-submodule.create-pr
20+
1221
- name: Checkout repository
1322
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
1423

1524
- name: Update Submodule
1625
run: |
1726
git submodule update --remote -- dd-java-agent/agent-jmxfetch/integrations-core
18-
- name: Download ghcommit CLI
19-
run: |
20-
curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
21-
chmod +x /usr/local/bin/ghcommit
2227
- name: Pick a branch name
2328
id: define-branch
2429
run: echo "branch=ci/update-jmxfetch-submodule-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
@@ -28,12 +33,21 @@ jobs:
2833
git push -u origin ${{ steps.define-branch.outputs.branch }} --force
2934
- name: Commit and push changes
3035
env:
31-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
36+
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
3237
run: |
33-
ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add dd-java-agent/agent-jmxfetch/integrations-core --message "Update agent-jmxfetch submodule"
38+
git config user.name "github-actions[bot]"
39+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
40+
if [[ -z "$(git status -s)" ]]; then
41+
echo "No changes to commit, exiting."
42+
exit 0;
43+
fi
44+
git checkout -b ${{ steps.define-branch.outputs.branch }}
45+
git add dd-java-agent/agent-jmxfetch/integrations-core
46+
git commit -m "Update agent-jmxfetch submodule"
47+
git push origin ${{ steps.define-branch.outputs.branch }}
3448
- name: Create pull request
3549
env:
36-
GH_TOKEN: ${{ github.token }}
50+
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
3751
run: |
3852
gh pr create --title "Update agent-jmxfetch submodule" \
3953
--base master \

0 commit comments

Comments
 (0)