Skip to content

Deploy through the Datadog Apps CLI instead of the build plugins - #105

Open
oliverli wants to merge 7 commits into
mainfrom
oliverli/deploy-via-apps-cli
Open

Deploy through the Datadog Apps CLI instead of the build plugins#105
oliverli wants to merge 7 commits into
mainfrom
oliverli/deploy-via-apps-cli

Conversation

@oliverli

@oliverli oliverli commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

With upload and publish API calls removed from the Datadog build plugins, the deploy action now runs datadog-apps deploy through npx — using the @datadog/apps-cli already installed in the app's node_modules when present, otherwise the version pinned by the new cli-version input (fetched into the runner user's npx cache; no global install).

Release note: the @datadog/apps-cli version currently on npm (0.0.1) is a stub — merge and release this action only after the real CLI version publishes under the same package name. No further code changes will be needed; workflows can pin the exact version via the new cli-version input.

Implementation details
  • src/main.ts: after the dependency install, the action runs npx --yes datadog-apps deploy in the app directory when node_modules/.bin/datadog-apps is installed (searching upward from the app directory, the way npx resolves binaries — monorepo-hoisted CLIs count); otherwise npx --yes --package @datadog/apps-cli@<cli-version> datadog-apps deploy. No npm install --global: no write access to npm's global prefix, no shared runner state mutated.
  • The binary check (not a package.json check) is deliberate: a custom install command can skip the section listing the CLI (for example npm ci --omit=dev), and bare npx datadog-apps would then fetch the unrelated registry package datadog-apps. With the binary absent the action falls back to the pinned --package form, so the unrelated package can never be fetched.
  • Every option is passed as a CLI flag — --site <datadog-site> (when set) and --version-name <GITHUB_SHA> (when set). Only DATADOG_API_KEY and DATADOG_APP_KEY go through the environment, which is where the CLI reads them from; this keeps the keys out of argv and runner logs.
  • DATADOG_APPS_UPLOAD_ASSETS is gone — nothing reads it anymore; the CLI drives the build (the project's own build script, package manager detected from lockfiles) and packages the bundle itself.
  • Inputs: removed build-command (the CLI owns the build invocation now); added optional datadog-site (else the CLI resolves from DD_SITE/DATADOG_SITE or datadog-app.config.json) and cli-version (default latest, ignored when the project has the CLI installed).
  • package.json version bumped 0.0.20.1.0 (breaking input removal, pre-1.0 minor).
  • Tests rewritten for the two-command flow (install, npx deploy); dist/ regenerated.

Changes to dependencies

None at build time. The action fetches @datadog/apps-cli at run time via npx when the project does not install it itself.

Review

Parallel reviewer agents plus the Codex review pass were addressed: the P1 (bare npx datadog-apps could fetch an unrelated registry package when the declared CLI was not actually installed) is fixed by selecting on the installed binary; the P2 (npm install --global needs global-prefix write access) is fixed by the npx-only design.

Breaking change for action consumers: the build-command input no longer exists — move any custom build logic into the project's build script.

The build plugins no longer upload or publish; @datadog/apps-cli owns
build, upload, and publish. Replace the build-command step (which relied
on DATADOG_APPS_UPLOAD_ASSETS=1) with a CLI install followed by
`datadog-apps deploy`. Site and version name (GITHUB_SHA) are passed as
CLI flags; only the API and app keys go through the environment.
@oliverli
oliverli requested review from a team as code owners September 3, 2026 21:41
@oliverli
oliverli requested a review from Scott-Meyer September 3, 2026 21:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T22:02:57.901629Z 0e406ff New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf2ff443d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.ts Outdated
When the app's package.json lists @datadog/apps-cli as a dependency,
run that pinned version with `npx datadog-apps deploy` instead of
installing the CLI globally. The cli-version input now applies only to
the global-install fallback.
npm accepts an empty string as a dependency range (equivalent to `*`),
so check property presence rather than the value when detecting
@datadog/apps-cli in package.json. Also narrow the malformed-package.json
comment to what the fallback actually guarantees.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e50f82972e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.ts Outdated
A custom install command can skip the section that lists the CLI (for
example `npm ci --omit=dev`), and bare `npx datadog-apps` then fetches
the unrelated registry package `datadog-apps` instead of failing. Search
node_modules/.bin upward from the app directory — the same way npx
resolves binaries — and fall back to a global install when the binary is
absent.
npm install --global requires write access to npm's global prefix, which
self-hosted runners may not grant, and mutates shared runner state. Run
the deploy through npx in both cases instead: the project's installed
binary when present, else npx --package @datadog/apps-cli@<cli-version>,
which fetches the pinned package into the runner user's npx cache.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e406ff2ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants