Skip to content

Commit f21ceea

Browse files
sarahchen6xopham
andauthored
Use dd-octo-sts to retrieve github release token (#9187)
* Add octo-sts policy * Add workflow and debugging * Fix policy * Run jobs in CI for now * Allow manual trigger for job * No dependencies for github token retrieval * Allow policy for all branches for now * Comment out debug call * Clean * Adjust policy * Update policy contents Co-authored-by: Christoph Hamsen <[email protected]> * Update policy to work on tags Co-authored-by: Christoph Hamsen <[email protected]> * Rework gitlab-ci workflow * Name change and fix needs block * Rework workflow again * Try original retrieval * Edit gitlab-ci.yml file * Clean * Remove comment * Move trust policy to a separate PR * Add aws ssm fallback * Split deployment to two jobs: new dd-octo-sts method and old aws method that is manually triggered --------- Co-authored-by: Christoph Hamsen <[email protected]>
1 parent 90125af commit f21ceea

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

.gitlab-ci.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ default:
193193
after_script:
194194
- *cgroup_info
195195

196+
# TODO: Add a pre-release check to see if the dd-octo-sts token is working.
196197
# Checks and fail early if central credentials are incorrect, indeed, when a new token is generated
197198
# on the central publisher protal, it invalidates the old one. This checks prevents going further.
198199
# See https://datadoghq.atlassian.net/wiki/x/Oog5OgE
@@ -804,14 +805,54 @@ deploy_to_maven_central:
804805

805806
deploy_artifacts_to_github:
806807
stage: publish
807-
image: registry.ddbuild.io/github-cli:v27480869-eafb11d-2.43.0
808+
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
809+
tags: [ "arch:amd64" ]
810+
id_tokens:
811+
DDOCTOSTS_ID_TOKEN:
812+
aud: dd-octo-sts
808813
rules:
809814
- if: '$POPULATE_CACHE'
810815
when: never
811816
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
812817
when: on_success
813818
# Requires the deploy_to_maven_central job to have run first (the UP-TO-DATE gradle check across jobs is broken)
814819
# This will deploy the artifacts built from the publishToSonatype task to the GitHub release
820+
needs:
821+
- job: deploy_to_maven_central
822+
# The deploy_to_maven_central job is not run for release candidate versions
823+
optional: true
824+
before_script:
825+
# Get token
826+
- dd-octo-sts version
827+
- dd-octo-sts debug --scope DataDog/dd-trace-java --policy self.gitlab.release
828+
- dd-octo-sts token --scope DataDog/dd-trace-java --policy self.gitlab.release > github-token.txt
829+
script:
830+
- gh auth login --with-token < github-token.txt
831+
- gh auth status # Maybe helpful to have this output in logs?
832+
- export VERSION=${CI_COMMIT_TAG##v} # remove "v" from front of tag to get version
833+
- cp workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar workspace/dd-java-agent/build/libs/dd-java-agent.jar # we upload two filenames
834+
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent.jar
835+
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-java-agent/build/libs/dd-java-agent-${VERSION}.jar
836+
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-api/build/libs/dd-trace-api-${VERSION}.jar
837+
- gh release upload --clobber --repo DataDog/dd-trace-java $CI_COMMIT_TAG workspace/dd-trace-ot/build/libs/dd-trace-ot-${VERSION}.jar
838+
after_script:
839+
- dd-octo-sts revoke -t $(cat github-token.txt)
840+
retry:
841+
max: 2
842+
when: always
843+
844+
# This is the original job that uses the AWS SSM token retrieval method. Allow manual triggering in case the dd-octo-sts token is not working.
845+
# TODO: Remove this job once the dd-octo-sts token is provably working.
846+
deploy_artifacts_to_github_old:
847+
stage: publish
848+
image: registry.ddbuild.io/github-cli:v27480869-eafb11d-2.43.0
849+
rules:
850+
- if: '$POPULATE_CACHE'
851+
when: never
852+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
853+
when: manual
854+
# Requires the deploy_to_maven_central job to have run first (the UP-TO-DATE gradle check across jobs is broken)
855+
# This will deploy the artifacts built from the publishToSonatype task to the GitHub release
815856
needs:
816857
- job: deploy_to_maven_central
817858
# The deploy_to_maven_central job is not run for release candidate versions

0 commit comments

Comments
 (0)