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: rework tag and labels for Docker CI Build #222

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

psyray
Copy link
Contributor

@psyray psyray commented Nov 7, 2024

This PR fix the Docker images CI build which not correctly set Arch leading to problem during install (manifest file not found).

  1. Removal of the platform matrix since we'll handle both architectures in a single build step

  2. Addition of the Docker meta step to manage tags and labels:

    • Configuration of tags for branches, PRs, semantic versions and SHA
    • Using a prefix rengine-${{ matrix.image }}- for each image
    • Tags will be automatically generated according to context (branch, tag, PR)
  3. Modification of the Build and push step:

    • Using tags and labels generated by metadata-action
    • Configuration of both platforms in a single step with platforms: linux/amd64,linux/arm64

This configuration should solve your issue because:

  • Tags will be managed consistently across all architectures
  • Multi-architecture build will be done in a single step
  • Metadata will be correctly applied to all architecture variants

The resulting images will have tags like:

  • rengine-web-v2.1.0
  • rengine-web-latest
  • rengine-web-2.1
  • rengine-web-2

And each tag will properly support both architectures (amd64 and arm64).

This configuration will also allow:

  1. On a release/X.Y.Z branch:

    • Semantic tags will be generated (X.Y.Z, X.Y)
    • No latest tag
  2. On the master branch:

    • The latest tag will be generated
    • Images will be tagged with the branch name
  3. During a workflow_dispatch:

    • On a release/* branch: version tags generation only
    • On master: latest tag generation
    • On other branches: tag with branch name

Thus, the latest tag remains exclusive to master, while still allowing appropriate version tags to be generated from release branches.

Summary by Sourcery

CI:

  • Rework Docker CI build to handle both amd64 and arm64 architectures in a single build step, removing the platform matrix.

- Added the BUILDX_NO_DEFAULT_ATTESTATIONS environment variable to the GitHub Actions build workflow configuration.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psyray - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please add documentation explaining why BUILDX_NO_DEFAULT_ATTESTATIONS is being disabled and what impact this has on the build process. This context is important for future maintainers.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

.github/workflows/build.yml Outdated Show resolved Hide resolved
- Removed the BUILDX_NO_DEFAULT_ATTESTATIONS environment variable.
- Replaced the manual versioning step with the docker/metadata-action to automate image tagging and labeling.
- Consolidated platform specification directly in the buildx step, removing the matrix platform configuration.
@psyray psyray changed the title ci: add BUILDX_NO_DEFAULT_ATTESTATIONS environment variable ci: rework tag and labels for Docker CI Build Nov 7, 2024
- Modified the GitHub Actions workflow to update the conditions under which semantic versioning tags are enabled.
- Introduced a new condition for enabling the latest tag when the reference is the master branch.
@psyray
Copy link
Contributor Author

psyray commented Nov 7, 2024

@sourcery-ai review

@Security-Tools-Alliance Security-Tools-Alliance deleted a comment from sourcery-ai bot Nov 7, 2024
Copy link
Contributor

sourcery-ai bot commented Nov 7, 2024

Reviewer's Guide by Sourcery

The PR updates the Docker CI build workflow by replacing manual version tagging with the docker/metadata-action and modifying how platform targets are specified.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Replace manual version tagging with docker/metadata-action
  • Remove manual version extraction from git refs
  • Add docker/metadata-action with comprehensive tag patterns for branches, PRs, semver, and latest
  • Configure image prefix and tag formatting using metadata action's flavor option
.github/workflows/build.yml
Streamline Docker build platform configuration
  • Remove platform matrix configuration
  • Directly specify platforms in build step
  • Add labels output from metadata action to build configuration
.github/workflows/build.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psyray - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The BUILDX_NO_DEFAULT_ATTESTATIONS environment variable mentioned in the description is not implemented in the workflow file. Please add it if it's intended to be part of this change.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@psyray psyray requested a review from AnonymousWP November 7, 2024 09:46
@psyray psyray self-assigned this Nov 7, 2024
@psyray psyray added the ci This is for CI-related PRs label Nov 7, 2024
@psyray psyray changed the base branch from master to release/2.1.1 November 7, 2024 12:26
@psyray psyray added this to the v2.1.1 release milestone Nov 7, 2024
@AnonymousWP AnonymousWP removed this from the v2.1.1 release milestone Nov 7, 2024
@Security-Tools-Alliance Security-Tools-Alliance deleted a comment from sourcery-ai bot Nov 7, 2024
@AnonymousWP AnonymousWP merged commit e86006a into release/2.1.1 Nov 7, 2024
11 of 13 checks passed
@AnonymousWP AnonymousWP deleted the test-ci-build branch November 7, 2024 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci This is for CI-related PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants