Skip to content

Commit 4ba40d2

Browse files
authored
ci: migrate GitHub release publishing to dd-octo-sts tokens (#3357)
* ci: migrate GitHub release publishing from AWS SSM to dd-octo-sts * chore(ci): add GitLab CI configuration for publishing releases with dd-octo-sts
1 parent 20fe229 commit 4ba40d2

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
issuer: https://gitlab.ddbuild.io
2+
3+
subject_pattern: "project_path:DataDog/apm-reliability/dd-trace-php:ref_type:tag:ref:ddtrace-.*"
4+
5+
permissions:
6+
contents: write

.gitlab/generate-package.php

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
- notify
8686
- verify
8787
- shared-pipeline # OCI packaging
88+
- pre-release
8889
- release
8990

9091
variables:
@@ -1403,6 +1404,33 @@
14031404
UPSTREAM_BRANCH: $CI_COMMIT_REF_NAME
14041405
UPSTREAM_COMMIT_SHA: $CI_COMMIT_SHA
14051406

1407+
"generate github token":
1408+
stage: pre-release
1409+
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
1410+
tags: [ "arch:amd64" ]
1411+
only:
1412+
refs:
1413+
- /^ddtrace-.*$/
1414+
id_tokens:
1415+
DDOCTOSTS_ID_TOKEN:
1416+
aud: dd-octo-sts
1417+
script:
1418+
- echo "Generating GitHub token for release..."
1419+
- dd-octo-sts debug --scope DataDog/dd-trace-php --policy gitlab-ci-publish-release
1420+
- dd-octo-sts token --scope DataDog/dd-trace-php --policy gitlab-ci-publish-release > github_token.txt
1421+
# Verify token works
1422+
- export GITHUB_TOKEN=$(cat github_token.txt)
1423+
- 'curl -f -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/DataDog/dd-trace-php | jq -r .name'
1424+
- echo "Token generated and verified successfully"
1425+
artifacts:
1426+
paths:
1427+
- github_token.txt
1428+
expire_in: 1 hour
1429+
when: on_success
1430+
variables:
1431+
# Prevent token from appearing in logs
1432+
GITHUB_TOKEN: "[MASKED]"
1433+
14061434
"publish release to github":
14071435
stage: release
14081436
image: registry.ddbuild.io/images/mirror/php:8.2-cli
@@ -1411,6 +1439,8 @@
14111439
refs:
14121440
- /^ddtrace-.*$/
14131441
needs:
1442+
- job: "generate github token"
1443+
artifacts: true
14141444
- job: "datadog-setup.php"
14151445
artifacts: true
14161446
- job: "package extension windows"
@@ -1420,5 +1450,12 @@
14201450
artifacts: true
14211451
<?php endforeach; ?>
14221452
script:
1423-
- if [ -z ${GITHUB_RELEASE_PAT} ]; then export GITHUB_RELEASE_PAT=$(aws ssm get-parameter --region us-east-1 --name ci.$CI_PROJECT_NAME.gh_token --with-decryption --query "Parameter.Value" --out text); fi
1424-
- php tooling/bin/create_release.php packages
1453+
- echo "Using pre-generated GitHub token for release..."
1454+
- export GITHUB_RELEASE_PAT=$(cat github_token.txt)
1455+
- php tooling/ci/create_release.php packages
1456+
after_script:
1457+
# Clean up token file (token will expire automatically in 1 hour)
1458+
- rm -f github_token.txt
1459+
variables:
1460+
# Prevent token from appearing in logs
1461+
GITHUB_RELEASE_PAT: "[MASKED]"

0 commit comments

Comments
 (0)