Skip to content

Instantly share code, notes, and snippets.

@staticaland
Last active February 4, 2026 08:24
Show Gist options
  • Select an option

  • Save staticaland/ce5f464c21e08b4b41fec0b08768afb1 to your computer and use it in GitHub Desktop.

Select an option

Save staticaland/ce5f464c21e08b4b41fec0b08768afb1 to your computer and use it in GitHub Desktop.
Datadog CI: GitHub Actions Metadata Upload - What metadata is collected when running datadog-ci upload commands in GitHub Actions

Datadog CI: GitHub Actions Metadata Upload

When running datadog-ci upload commands in a GitHub Actions workflow, the CLI can automatically detect the CI environment and upload GitHub metadata to Datadog. However, not all upload commands include this metadata.

Important: Which Commands Upload GitHub Metadata?

Command Uploads GitHub CI Metadata?
junit upload Yes
coverage upload Yes
git-metadata upload No

The git-metadata upload command only uploads git repository data (commit SHA, repository URL, tracked files). It does not include GitHub Actions workflow/job metadata.


Related Datadog Products

These commands feed into different Datadog products:

Command Datadog Product Documentation
junit upload Test Visibility Track test results, flakiness, performance
coverage upload Code Coverage Track code coverage metrics
git-metadata upload Source Code Integration Link stack traces to source code
dora deployment DORA Metrics Software delivery performance metrics

Note: The GitHub CI metadata collected by junit upload and coverage upload is used to correlate test results with CI pipelines in Test Visibility / Code Coverage. It is not used for DORA metrics—those require the separate dora deployment command.


git-metadata upload - What It Actually Uploads

Call Path

  1. Command entry point: packages/base/src/commands/git-metadata/upload.ts:67-152

  2. Payload generation via getCommitInfo(): packages/base/src/commands/git-metadata/git.ts:61-76

  3. Payload structure in CommitInfo.asMultipartPayload(): packages/base/src/commands/git-metadata/interfaces.ts:14-31

  4. GitDB sync (packfiles): packages/base/src/commands/git-metadata/gitdb.ts:67-149

Data Uploaded

The git-metadata upload command uploads:

{
  "cli_version": "...",
  "git_commit_sha": "abc123...",
  "git_repository_url": "https://github.com/org/repo",
  "type": "repository"
}

Plus:

  • List of tracked files (from git ls-files)
  • Git packfiles containing commit history

No GitHub Actions environment variables are read or uploaded.


junit upload / coverage upload - GitHub Metadata Included

These commands do upload GitHub Actions metadata via getCISpanTags():

packages/plugin-junit/src/commands/upload.ts:250-262

const ciSpanTags = getCISpanTags() // GitHub environment variables
const gitSpanTags = await getGitMetadata() // Git repository info
const userGitSpanTags = getUserGitSpanTags() // User-provided overrides

How GitHub Actions is Detected

The CLI checks for GITHUB_ACTIONS or GITHUB_ACTION environment variables:

packages/base/src/helpers/ci.ts:329-332

GitHub Metadata Collected

CI Pipeline Information

Environment Variable Datadog Tag Description
GITHUB_RUN_ID ci.pipeline.id Workflow run ID
GITHUB_WORKFLOW ci.pipeline.name Workflow name
GITHUB_RUN_NUMBER ci.pipeline.number Run number
GITHUB_RUN_ATTEMPT Run attempt Attempt number for re-runs
GITHUB_WORKSPACE ci.workspace_path Working directory

CI Job Information

Environment Variable Datadog Tag Description
GITHUB_JOB ci.job.name, ci.job.id Job identifier
DD_GITHUB_JOB_NAME ci.job.name Custom override for job name

Git Information

Environment Variable Datadog Tag Description
GITHUB_SHA git.commit.sha Commit SHA
GITHUB_REPOSITORY git.repository_url Repository (org/repo format)
GITHUB_REF git.branch Branch reference
GITHUB_HEAD_REF git.branch PR head branch (takes precedence)
GITHUB_SERVER_URL Used for URL construction GitHub server URL

Pull Request Information

When running in a PR context (detected via GITHUB_BASE_REF):

Source Datadog Tag Description
GITHUB_BASE_REF git.pull_request.base_branch PR base branch
Event payload git.commit.sha PR head SHA
Event payload PR base SHA Base commit SHA
Event payload pr.number Pull request number

PR metadata is extracted from the GitHub event payload file at GITHUB_EVENT_PATH:

packages/base/src/helpers/ci.ts:381-388

URL Construction

The CLI constructs pipeline and job URLs:

Pipeline URL: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
Job URL:      ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/job/${JOB_ID}

packages/base/src/helpers/ci.ts:356-369

Special Feature: Job Name Extraction from Logs

GitHub Actions doesn't expose the human-readable job display name in environment variables. The CLI extracts it from diagnostic logs:

packages/base/src/helpers/ci.ts:1077-1164

Tag Definitions

All CI/CD tags are defined in:

packages/base/src/helpers/tags.ts:1-60

CI Environment Variables Passed to Backend

The getCIEnv() function filters GitHub-specific environment variables sent to Datadog:

  • GITHUB_SERVER_URL
  • GITHUB_REPOSITORY
  • GITHUB_RUN_ID
  • GITHUB_RUN_ATTEMPT
  • GITHUB_JOB
  • DD_GITHUB_JOB_NAME

packages/base/src/helpers/ci.ts:921-981

Security: Sensitive Information Filtering

Repository URLs are sanitized to remove credentials before uploading:

packages/base/src/helpers/ci.ts:356


Based on datadog-ci commit 604463d9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment