Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Include build information in Docker image labels #39047

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Feb 6, 2025

Description

Completion of #39025.

We're able to see the labels with Docker API (script written by Cursor):

shot-2025-02-06-04-41-44

Implemented by these two Cursor prompts 🙂

shot-2025-02-06-05-16-29

shot-2025-02-06-05-16-43

Automation

/test sanity

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Docker image builds now include added metadata (commit revision, source, and version details) to improve image traceability and version tracking.
  • Chores

    • CI workflows have been streamlined to consistently generate and apply metadata labels, ensuring reliable and automated image processing across all pipelines.

Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

This pull request updates multiple GitHub Actions workflows to consistently generate an info.json file containing metadata such as commit SHA, repository, and version details. The new output, identified by info_json, is now used to add Docker image labels in several build steps. Additionally, the associated shell script is improved to output these values to GITHUB_OUTPUT, ensuring that subsequent workflow steps can reference the metadata without conditional checks.

Changes

File(s) Change Summary
.github/workflows/ad-hoc-docker-image.yml
.github/workflows/build-docker-image.yml
.github/workflows/github-release.yml
.github/workflows/on-demand-build-docker-image-deploy-preview.yml
Added a new info_json step to always generate an info.json file capturing commit SHA, repository, and version info; updated Docker build steps with new labels (org.opencontainers.image.revision, ...image.source, ...image.version); simplified script invocation and adjusted minor comment formatting.
scripts/generate_info_json.sh Modified to output commitSha, repo, and version values to GITHUB_OUTPUT when running in GitHub Actions; updated comments to document the new output mechanism.

Sequence Diagram(s)

sequenceDiagram
  participant W as Workflow Runner
  participant I as info_json Step
  participant D as Docker Build Step
  
  W->>I: Execute generate_info_json.sh
  I-->>W: Return commitSha, repo, version
  W->>D: Run Docker build with new labels using outputs
  D-->>W: Build image enriched with metadata
Loading

Possibly related PRs

Suggested reviewers

  • pratapaprasanna
  • mohanarpit
  • abhvsn

Poem

In lines of YAML and bash we trust,
A metadata spark ignites robust.
info.json shines in every build,
Labels and outputs, perfectly fulfilled.
Cheers to our code—a vibrant gust!
🚀 Happy builds, no bugs to adjust!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6604f36 and 648dc85.

📒 Files selected for processing (5)
  • .github/workflows/ad-hoc-docker-image.yml (2 hunks)
  • .github/workflows/build-docker-image.yml (2 hunks)
  • .github/workflows/github-release.yml (3 hunks)
  • .github/workflows/on-demand-build-docker-image-deploy-preview.yml (3 hunks)
  • scripts/generate_info_json.sh (1 hunks)
🔇 Additional comments (9)
scripts/generate_info_json.sh (1)

43-50: GitHub Actions Output Enhancement
The new block correctly checks for the presence of GITHUB_OUTPUT and appends the key metadata values. This integration improves downstream usability in GitHub Actions. Just verify that all consuming steps reference these outputs as intended.

.github/workflows/ad-hoc-docker-image.yml (2)

93-96: Improved Metadata Generation Step
Adding the Generate info.json step with an explicit id: info_json and passing ${{ inputs.tag }} enhances traceability in the ad-hoc Docker image build. Ensure that the input tag is always supplied or has a sensible default.


127-130: Enhanced Docker Image Labels
The newly added labels populate the image with build revision, repository source, and version information. This extra metadata is a smart move toward better artifact traceability.

.github/workflows/build-docker-image.yml (2)

72-76: Metadata Generation in Build Workflow
Introducing the info_json step ensures consistent metadata generation. Note that the script is invoked without parameters here, so confirm that its default behavior meets your requirements.


107-109: Docker Build Label Integration
Appending the Docker build arguments with labels drawn from the info_json outputs enriches the image with useful metadata. This consistency across workflows is a definite plus.

.github/workflows/github-release.yml (2)

249-253: Metadata Generation in Release Workflow
The new step generating info.json integrates build metadata into the release process. This improvement helps maintain a consistent versioning scheme across your Docker images—just ensure the output aligns with release expectations.


281-284: Consistent Labeling for Release Images
Embedding org.opencontainers.image.revision, source, and version into the Docker image via labels is a great enhancement. This change will simplify tracking and debugging of release artifacts.

.github/workflows/on-demand-build-docker-image-deploy-preview.yml (2)

172-175: Metadata Generation in On-Demand Workflow
The inclusion of the Generate info.json step ensures that build metadata is available for on-demand preview deployments. Verify that the metadata output is correctly captured in this context.


211-214: Docker Image Label Consistency
Consistently using the metadata outputs to label the Docker images in the push-image step reinforces uniformity across workflows. Make sure these labels reflect the correct build details during deployment.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog CI labels Feb 6, 2025
@sharat87 sharat87 marked this pull request as ready for review February 6, 2025 05:24
@sharat87 sharat87 merged commit b442ca9 into release Feb 6, 2025
20 checks passed
@sharat87 sharat87 deleted the ci/docker-image-labels branch February 6, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants