Skip to content

Comments

feat: add git metadata to deploys via v1alpha1 API#1990

Merged
jeremybeard merged 8 commits intomainfrom
feat/deploy-git-metadata
Jan 14, 2026
Merged

feat: add git metadata to deploys via v1alpha1 API#1990
jeremybeard merged 8 commits intomainfrom
feat/deploy-git-metadata

Conversation

@jlaneve
Copy link
Contributor

@jlaneve jlaneve commented Dec 15, 2025

Summary

  • Adds support for including git metadata (commit SHA, branch, author, etc.) in deploy requests
  • Uses the v1alpha1 API which supports the git metadata field, providing better traceability for deployments
  • Reuses existing retrieveLocalGitMetadata() logic from bundle deploys for consistency

Tested this against dev, where the API changes are currently deployed and it works (screenshot below). Tested this against prod, where the API changes are not yet deployed, and we disregard the extra fields so no harm in merging this earlier.

Screenshot 2025-12-18 at 1 16 06 PM

Changes

  • Add deploy.git_metadata config option (default: true)
  • Add ASTRO_DEPLOY_GIT_METADATA env var support for CI/CD overrides
  • Add createDeployWithGit() function using v1alpha1 core API
  • Fall back to git commit message for deploy description if not provided

Behavior

When enabled (default), deploys will:

  • Include git metadata (provider, account, repo, branch, commit SHA, commit URL, author)
  • Auto-populate description from commit message if not specified
  • Skip git metadata if repository has uncommitted changes (matches bundle deploy behavior)

Users can opt out:

# Via config
astro config set deploy.git_metadata false

# Via environment variable
ASTRO_DEPLOY_GIT_METADATA=false astro deploy

Test plan

  • Existing deploy tests pass
  • Manual test: deploy with git metadata enabled
  • Manual test: deploy with git metadata disabled
  • Manual test: deploy with uncommitted changes (should skip git metadata)
  • Manual test: deploy without description (should use commit message)

🤖 Generated with Claude Code

jlaneve and others added 2 commits December 15, 2025 14:17
Add support for including git metadata (commit SHA, branch, author, etc.)
in deploy requests. This uses the v1alpha1 API which supports the git
metadata field, providing better traceability for deployments.

Changes:
- Add `deploy.git_metadata` config option (default: true)
- Add `ASTRO_DEPLOY_GIT_METADATA` env var support
- Add `createDeployWithGit()` function using v1alpha1 API
- Reuse existing `retrieveLocalGitMetadata()` from bundle deploys
- Fall back to git commit message for deploy description if not provided

When enabled (default), deploys will:
- Include git metadata (provider, account, repo, branch, commit SHA, URL, author)
- Auto-populate description from commit message if not specified
- Skip git metadata if repository has uncommitted changes

Users can opt out by setting `deploy.git_metadata: false` in config
or `ASTRO_DEPLOY_GIT_METADATA=false` environment variable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add commit message fallback for description even when git metadata is disabled
- Disable git metadata in deploy tests to preserve existing mock behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coveralls-official
Copy link

coveralls-official bot commented Dec 15, 2025

Pull Request Test Coverage Report for Build 63e5d3b1-2e7e-460c-960e-7881682e07aa

Details

  • 21 of 32 (65.63%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 33.146%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cloud/deploy/deploy.go 13 24 54.17%
Totals Coverage Status
Change from base Build de52b69a-1e0e-4ca1-b748-dc755f6e28f1: 0.01%
Covered Lines: 20861
Relevant Lines: 62937

💛 - Coveralls

jlaneve and others added 5 commits December 15, 2025 14:48
Use astrocore.CreateDeployRequestType constants (DAG, IMAGE) instead of
raw strings for better type safety.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Remove the config flag approach and update the deploy implementation
to use v1beta1 API exclusively with git metadata support. This requires
the backend changes from astro PR #35907 which adds git metadata support
to the v1beta1 CreateDeploy endpoint.

Changes:
- Regenerate astro-client-platform-core with git metadata types
- Update Deploy() to use v1beta1 CreateDeployWithResponse with git metadata
- Remove v1alpha1 code path and createDeployWithGit function
- Remove DeployGitMetadata config flag
- Fix IsHibernating pointer type change from client regeneration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add configuration to enable/disable git metadata in deploys:
- Add `deploy.git_metadata` config option (default: true)
- Add `ASTRO_DEPLOY_GIT_METADATA` env var for CI/CD overrides
- Add tests for config and env var functionality

Users can opt out of git metadata via:
  astro config set deploy.git_metadata false
  ASTRO_DEPLOY_GIT_METADATA=false astro deploy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…e.go

- Use dynamic provider instead of hardcoded GITHUB in deploy.go
- Use pre-computed CommitUrl in bundle.go instead of reconstructing it
- Consistent field ordering in both files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@jlaneve jlaneve marked this pull request as ready for review December 18, 2025 18:36
Copy link
Contributor

@neel-astro neel-astro left a comment

Choose a reason for hiding this comment

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

Left tiny nit Q, but otherwise functionally LGTM

var deployGit *astrocore.DeployGit
var commitMessage string
gitMetadataEnabled := config.CFG.DeployGitMetadata.GetBool()
if envVal := os.Getenv("ASTRO_DEPLOY_GIT_METADATA"); envVal != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

The config is enabled by default, so why do we need a separate env var to turn it off, apart from being able to set it via config?
i.e., for anyone who does not need it can, as of now, do it via astro config set -g deploy.git_metadata false in CI/CD as well.

Branch: deployGit.Branch,
CommitSha: deployGit.CommitSha,
CommitUrl: fmt.Sprintf("https://github.com/%s/%s/commit/%s", deployGit.Account, deployGit.Repo, deployGit.CommitSha),
CommitUrl: deployGit.CommitUrl,
Copy link
Contributor

Choose a reason for hiding this comment

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

good cleanup ❤️

Comment on lines 372 to 409
repository := deploy.ImageRepository
repository := imageRepository
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we may not need this. Declaring the variable and using it only in one place, that too quite far apart, reduces overall code readability.

Address PR review feedback:
- Remove env var override for git metadata config (users can use
  `astro config set -g deploy.git_metadata false` instead)
- Revert intermediate imageRepository variable

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@jeremybeard jeremybeard merged commit 7075639 into main Jan 14, 2026
2 of 5 checks passed
@jeremybeard jeremybeard deleted the feat/deploy-git-metadata branch January 14, 2026 19:50
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