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

Dev 105/preview githubaction #2879

Merged
merged 48 commits into from
Jan 3, 2025
Merged

Conversation

codechirag123
Copy link
Collaborator

@codechirag123 codechirag123 commented Dec 9, 2024

Modified the actions and resolved the action failures

Summary by CodeRabbit

  • New Features

    • Introduced new Dockerfiles for backoffice-v2, kyb-app, and workflows-dashboard applications.
    • Added new scripts for production builds in package.json for backoffice-v2, kyb-app, and workflows-dashboard.
    • Added a new script for starting the application in preview mode in the package.json for workflows-service.
  • Improvements

    • Enhanced workflow configurations for deploying and destroying temporary environments, allowing for manual triggers and improved job conditions.
    • Updated permissions for workflows to include write access for packages.
    • Added new input parameters to workflow configurations for better clarity and functionality.
    • Included a new step for pushing the Docker image tagged as latest in the deployment workflow.
  • Bug Fixes

    • Adjusted environment name sanitization logic for better consistency.
  • Chores

    • Revised dependencies for build jobs to establish clearer sequences.
    • Modified workflow configurations to include new input parameters and adjust checkout behavior.

Copy link

changeset-bot bot commented Dec 9, 2024

⚠️ No Changeset found

Latest commit: a2fa32c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

Walkthrough

This pull request introduces comprehensive updates to GitHub Actions workflows and application configurations across multiple projects. The changes focus on enhancing preview environment deployment, build processes, and Docker configurations. Key modifications include updating workflow permissions, adding manual trigger capabilities, adjusting job dependencies, and creating preview Dockerfiles for backoffice, KYB, and workflows dashboard applications. The changes streamline the deployment and build processes for different application components.

Changes

File Change Summary
.github/workflows/build-preview-environment.yml - Added workflow_dispatch trigger
- Updated permissions to write access
- Modified job dependencies and conditions
- Added file parameters for Docker builds
.github/workflows/build-push-docker-images.yml - Added new file input parameter
- Added packages: write permission
- Removed sparse checkout options
- Updated version retrieval logic
.github/workflows/destroy-preview-environment.yml - Expanded job trigger conditions
- Modified environment name sanitization
apps/backoffice-v2/Dockerfile.preview - New Dockerfile for preview environment
- Uses Node.js 18.17.1
- Configures build and run processes
apps/backoffice-v2/package.json - Added prod:next script for production build
apps/kyb-app/Dockerfile.preview - New Dockerfile for preview environment
- Uses Node.js 18.17.1
- Configures build and run processes
apps/kyb-app/package.json - Added prod:next script for production build
apps/workflows-dashboard/Dockerfile.preview - New Dockerfile for preview environment
- Uses Node.js 18.17.1
- Configures build and run processes
apps/workflows-dashboard/package.json - Added prod:next script for production build
services/workflows-service/package.json - Added start:preview script for streamlined database preparation and application start
.github/workflows/deploy-wf-service.yml - Added step to push Docker image tagged as latest
- Structured handling of environment inputs

Possibly Related PRs

Suggested Reviewers

  • alonp99

Poem

🐰 Workflows dance, preview takes flight,
Docker containers shine so bright,
Branches merge with gentle grace,
Automated magic leaves no trace,
CodeRabbit hops with pure delight! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2fa32c and 9a3e22e.

📒 Files selected for processing (3)
  • apps/backoffice-v2/package.json (1 hunks)
  • apps/kyb-app/package.json (1 hunks)
  • services/workflows-service/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/kyb-app/package.json
  • services/workflows-service/package.json
  • apps/backoffice-v2/package.json

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
.github/workflows/build-preview-environment.yml (1)

71-71: Fix formatting: Add space after comma in job dependencies

Add space after comma in the needs array for better readability.

-    needs: [deploy-dev-pr-environment,build-wf-service]
+    needs: [deploy-dev-pr-environment, build-wf-service]
-    needs: [deploy-dev-pr-environment,build-backoffice]
+    needs: [deploy-dev-pr-environment, build-backoffice]
-    needs: [deploy-dev-pr-environment,build-kyb]
+    needs: [deploy-dev-pr-environment, build-kyb]

Also applies to: 81-81, 91-91

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 71-71: too few spaces after comma

(commas)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fe55bfa and 9797142.

📒 Files selected for processing (3)
  • .github/workflows/build-preview-environment.yml (5 hunks)
  • .github/workflows/build-push-docker-images.yml (2 hunks)
  • .github/workflows/destroy-preview-environment.yml (3 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 71-71: too few spaces after comma

(commas)


[warning] 81-81: too few spaces after comma

(commas)


[warning] 91-91: too few spaces after comma

(commas)

🔇 Additional comments (8)
.github/workflows/build-push-docker-images.yml (2)

30-30: LGTM: Permission addition is appropriate

The addition of packages: write permission is necessary for pushing Docker images to the GitHub Container Registry (ghcr.io).


Line range hint 52-58: Verify the impact of tag name change

The tag prefix has been changed from workflows-service@ to workflow-service@. While this appears to be a bug fix, we should verify there are no existing tags using the old prefix.

✅ Verification successful

Let me verify if there are any references to the old tag prefix in the codebase to ensure we haven't missed any occurrences.


No existing tags or references found with either prefix

Based on the verification results, there are no existing tags with either the old prefix (workflows-service@) or the new prefix (workflow-service@). Additionally, there are no references to either prefix in the codebase. This suggests that this is likely a new tagging convention being introduced, and the change from workflows-service@ to workflow-service@ won't impact any existing tags or references.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existing tags with both old and new prefixes
echo "Tags with old prefix (workflows-service@):"
git tag -l "workflows-service@*" | sort -V

echo "Tags with new prefix (workflow-service@):"
git tag -l "workflow-service@*" | sort -V

Length of output: 276


Script:

#!/bin/bash
# Search for any references to the old tag prefix in the codebase
echo "Files containing 'workflows-service@':"
rg -l "workflows-service@"

echo -e "\nFiles containing 'workflow-service@':"
rg -l "workflow-service@"

Length of output: 242

🧰 Tools
🪛 actionlint (1.7.4)

49-49: if: condition "${{ inputs.image_name }} == 'workflows-service'" is always evaluated to true because extra characters are around ${{ }}

(if-cond)


51-51: shellcheck reported issue in this script: SC2116:style:1:19: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'

(shellcheck)

.github/workflows/build-preview-environment.yml (3)

14-16: LGTM: Permission updates are appropriate

The expanded write permissions are necessary for:

  • contents: write: Checking out code and managing repository contents
  • pull-requests: write: Updating PR status and labels
  • packages: write: Publishing Docker images

23-23: LGTM: Manual trigger support added

Adding workflow_dispatch support improves operational flexibility by allowing manual reruns when needed.


49-51: Verify consistent branch name trimming across workflows

The branch name trimming has been changed from 8 to 7 characters. This change must be consistent across all workflows to prevent environment name mismatches.

✅ Verification successful

Branch name trimming is consistent across workflows

The verification shows that both workflow files (build-preview-environment.yml and destroy-preview-environment.yml) use the same trimming length of 7 characters (cut -c 1-7), ensuring consistent environment naming.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for branch name trimming across all workflow files
echo "Checking branch name trimming in workflow files:"
rg -A 1 "cut -c" .github/workflows/

Length of output: 657

.github/workflows/destroy-preview-environment.yml (3)

21-21: LGTM: Manual trigger support added

Adding workflow_dispatch support allows manual cleanup of preview environments when needed.


46-48: LGTM: Branch name trimming aligned with build workflow

The branch name trimming is now consistent with the build workflow, using 7 characters.


63-64: LGTM: Manual trigger condition added

The destroy job's conditions now properly include the manual trigger case.

@codechirag123 codechirag123 added the deploy-pr For running PR environment label Dec 9, 2024
@codechirag123 codechirag123 added deploy-pr For running PR environment and removed deploy-pr For running PR environment labels Dec 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
.github/workflows/destroy-preview-environment.yml (1)

21-26: Fix trailing whitespace and LGTM!

The job conditions are well-structured and cover all necessary scenarios. However, there's a trailing space on line 22 that should be removed.

-      (github.event_name == 'pull_request' && github.event.action == 'unlabeled' && github.event.label.name == 'deploy-pr') 
+      (github.event_name == 'pull_request' && github.event.action == 'unlabeled' && github.event.label.name == 'deploy-pr')
🧰 Tools
🪛 yamllint (1.35.1)

[error] 22-22: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9797142 and 8eddba3.

📒 Files selected for processing (1)
  • .github/workflows/destroy-preview-environment.yml (3 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/destroy-preview-environment.yml

[error] 22-22: trailing spaces

(trailing-spaces)

🔇 Additional comments (3)
.github/workflows/destroy-preview-environment.yml (3)

68-69: LGTM! Manual trigger support added consistently

The addition of workflow_dispatch trigger support is well-aligned with the manual trigger capability in the deploy job, maintaining consistency throughout the workflow.


51-53: Verify the impact of reducing branch name length

The change from 8 to 7 characters in TRIMMED_BRANCH_NAME could affect existing environments or related workflows. Let's verify this change is consistent across all workflows.

✅ Verification successful

Branch name trimming length is consistent across workflows

The change to 7 characters is already consistent with the build-preview-environment.yml workflow, which also uses cut -c 1-7. Both the build and destroy workflows are aligned in their branch name trimming approach.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other workflows that might be affected by the branch name length change

# Search for similar branch name trimming patterns
rg -l 'cut -c 1-[0-9]' .github/workflows/

Length of output: 141


Script:

#!/bin/bash
# Let's check the exact trimming length in build-preview-environment.yml
rg 'cut -c 1-[0-9]' .github/workflows/build-preview-environment.yml -A 2 -B 2

Length of output: 466


Line range hint 74-91: Verify GIT_TOKEN permissions for cross-repo operations

The workflow uses secrets.GIT_TOKEN to trigger a workflow in the cloud-infra-config repository. Please ensure this token has sufficient permissions to create repository dispatch events in the target repository.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 22-22: trailing spaces

(trailing-spaces)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (3)
apps/backoffice-v2/Dockerfile.preview (2)

13-13: Inconsistent PATH environment variable format

The PATH variable uses an absolute path /app/node_modules/.bin while the kyb-app uses a relative path ./node_modules/.bin.

Maintain consistency across Dockerfiles:

- ENV PATH="$PATH:/app/node_modules/.bin"
+ ENV PATH="$PATH:./node_modules/.bin"

1-17: Consider creating a base Dockerfile template

Both Dockerfiles (kyb-app and backoffice-v2) share almost identical configuration.

Consider:

  1. Creating a base Dockerfile template with ARG variables for customization:
# Base Dockerfile.template
ARG NODE_VERSION=18.17.1
FROM node:${NODE_VERSION}-bullseye-slim

ARG PORT=3000
ARG APP_USER=appuser

WORKDIR /app

# Security setup
RUN groupadd -r ${APP_USER} && useradd -r -g ${APP_USER} ${APP_USER}

COPY package.json .
RUN npm install --strict-peer-deps
COPY . .
RUN npm run build --verbose

ENV PATH="$PATH:./node_modules/.bin"
EXPOSE ${PORT}

USER ${APP_USER}
CMD ["npm", "run", "prod:next", "--host"]
  1. Using it in individual Dockerfiles:
# apps/backoffice-v2/Dockerfile.preview
ARG NODE_VERSION=18.17.1
ARG PORT=5137
ARG APP_USER=backoffice

INCLUDE Dockerfile.template
.github/workflows/build-preview-environment.yml (1)

72-72: Fix formatting: Add space after comma in job dependencies

The job dependencies list has formatting issues. Add a space after each comma for better readability.

-    needs: [deploy-dev-pr-environment,build-wf-service]
+    needs: [deploy-dev-pr-environment, build-wf-service]
-    needs: [deploy-dev-pr-environment,build-backoffice]
+    needs: [deploy-dev-pr-environment, build-backoffice]
-    needs: [deploy-dev-pr-environment,build-kyb]
+    needs: [deploy-dev-pr-environment, build-kyb]

Also applies to: 83-83, 94-94

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 72-72: too few spaces after comma

(commas)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8eddba3 and 8657803.

📒 Files selected for processing (8)
  • .github/workflows/build-preview-environment.yml (3 hunks)
  • .github/workflows/build-push-docker-images.yml (3 hunks)
  • apps/backoffice-v2/Dockerfile.preview (1 hunks)
  • apps/backoffice-v2/package.json (1 hunks)
  • apps/kyb-app/Dockerfile.preview (1 hunks)
  • apps/kyb-app/package.json (1 hunks)
  • apps/workflows-dashboard/Dockerfile.preview (1 hunks)
  • apps/workflows-dashboard/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/workflows-dashboard/Dockerfile.preview
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 72-72: too few spaces after comma

(commas)


[warning] 83-83: too few spaces after comma

(commas)


[warning] 94-94: too few spaces after comma

(commas)

🔇 Additional comments (5)
apps/workflows-dashboard/package.json (1)

11-11: Verify script usage across applications

Ensure consistent usage of the new prod:next script across all applications using Vite.

✅ Verification successful

Consistent prod:next script configuration found across Vite applications

The verification shows that multiple applications are using the same prod:next script configuration vite build && vite, which indicates consistency in the build and serve commands across the Vite applications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for prod:next script usage
fd -e json package.json -x jq -r '.scripts["prod:next"] // empty' {} \;

# Check for vite configuration
fd -e ts -e js vite.config -x cat {} \;

Length of output: 8767

.github/workflows/build-push-docker-images.yml (2)

26-29: LGTM! Workflow enhancements look good

The changes improve the workflow by:

  • Adding file parameter for flexible Dockerfile selection
  • Adding necessary packages write permission
  • Adding conditional build arguments for workflows-service

Also applies to: 34-34, 123-125


56-58: Verify the version tag pattern change

The version tag pattern has changed from workflows-service@* to workflow-service@*. Please ensure this change is intentional and consistent with your tagging strategy.

.github/workflows/build-preview-environment.yml (2)

14-16: LGTM! Workflow improvements look good

The changes enhance the workflow by:

  • Adding manual trigger support
  • Adding necessary write permissions
  • Specifying correct Dockerfile for each service
  • Establishing clear build dependencies

Also applies to: 23-23, 69-69, 80-80, 91-91, 102-102


49-49: Verify impact of environment name length change

The branch name trimming has been reduced from 8 to 7 characters. This change could affect existing preview environments or cause naming conflicts.

✅ Verification successful

Let me gather more information about the environment naming pattern and its usage.


Based on the gathered information, I can now provide the final response:

Environment name length change is safe to proceed

The change from 8 to 7 characters for branch name trimming is safe because:

  • The same change is consistently applied in both creation (build-preview-environment.yml) and cleanup (destroy-preview-environment.yml) workflows
  • No other files in the codebase reference the preview environment names directly
  • Recent workflow runs show no active, long-running preview environments that could be affected
  • The change maintains uniqueness as demonstrated by the branch name samples (e.g., 'origin-d' vs 'origin-')
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential conflicts with existing environment names
echo "Checking for potential naming conflicts:"
git branch -r | while read -r branch; do
  sanitized=$(echo "$branch" | tr "/" "-")
  old_name=${sanitized:0:8}
  new_name=${sanitized:0:7}
  if [ "$old_name" != "$new_name" ]; then
    echo "Branch: $branch"
    echo "  Old name (8 chars): $old_name"
    echo "  New name (7 chars): $new_name"
  fi
done

Length of output: 841


Script:

#!/bin/bash
# Check the workflow file for environment name usage
echo "Checking environment name usage in workflow:"
rg -A 5 "TRIMMED_BRANCH_NAME" .github/workflows/

# Check for any other files that might use the environment name
echo -e "\nChecking other files for environment name references:"
rg "preview-env-" 

# Check if there are any existing preview environments
echo -e "\nChecking for existing preview environments in workflow runs:"
gh run list --workflow=build-preview-environment.yml --json conclusion,headBranch,databaseId --limit 10

Length of output: 2853

apps/kyb-app/Dockerfile.preview Show resolved Hide resolved
Comment on lines 1 to 17
FROM node:18.17.1-bullseye-slim

WORKDIR /app

COPY ./package.json .

RUN npm install --legacy-peer-deps

COPY . .

RUN npm run build --verbose

ENV PATH="$PATH:./node_modules/.bin"

EXPOSE 5201

CMD ["npm", "run", "prod:next", "--host"]
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider implementing Docker best practices

Several improvements could enhance security and efficiency:

  1. Add multi-stage build to reduce image size:
# Build stage
FROM node:18.17.1-bullseye-slim AS builder
WORKDIR /app
COPY package.json .
RUN npm install --strict-peer-deps
COPY . .
RUN npm run build --verbose

# Production stage
FROM node:18.17.1-bullseye-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY package.json .
RUN npm install --production
ENV PATH="$PATH:./node_modules/.bin"
EXPOSE 5201
USER node
CMD ["npm", "run", "prod:next", "--host"]
  1. Add security measures:
+ RUN groupadd -r appuser && useradd -r -g appuser appuser
+ USER appuser
  1. Add health check:
+ HEALTHCHECK --interval=30s --timeout=3s \
+   CMD curl -f http://localhost:5201/health || exit 1

Committable suggestion skipped: line range outside the PR's diff.

apps/kyb-app/Dockerfile.preview Show resolved Hide resolved
@@ -8,6 +8,7 @@
"dev": "vite --host",
"start": "vite",
"build": "tsc && vite build",
"prod:next": "vite build && vite",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review production deployment configuration

The prod:next script runs vite without production mode after building, which could expose development features.

Consider:

  1. Using vite preview for production serving:
- "prod:next": "vite build && vite",
+ "prod:next": "vite build && vite preview --host",
  1. Adding environment configuration:
- "prod:next": "vite build && vite",
+ "prod:next": "NODE_ENV=production vite build && vite preview --host",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"prod:next": "vite build && vite",
"prod:next": "NODE_ENV=production vite build && vite preview --host",

@@ -7,6 +7,7 @@
"dev": "vite",
"start": "vite",
"build": "tsc && vite build",
"prod:next": "vite build && vite",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix potentially incorrect production script

The prod:next script appears to be running Vite in development mode after building for production. This could lead to serving the development version instead of the production build.

Consider one of these alternatives:

-    "prod:next": "vite build && vite",
+    "prod:next": "vite build && vite preview",

or

-    "prod:next": "vite build && vite",
+    "prod:next": "vite build && serve dist",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"prod:next": "vite build && vite",
"prod:next": "vite build && vite preview",

@@ -42,6 +42,7 @@
"start": "vite",
"dev": "vite",
"build": "cross-env NODE_OPTIONS=--max-old-space-size=32768 vite build",
"prod:next": "vite build && vite",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review the "prod:next" script implementation

The new script "prod:next": "vite build && vite" has potential issues:

  1. Running vite after vite build starts the dev server with source files, not the built files
  2. For production environments, you should serve the built files using vite preview
  3. The existing preview script already handles this use case correctly

Consider one of these alternatives:

-    "prod:next": "vite build && vite",
+    "prod:next": "vite build && vite preview",

Or use the existing preview script:

# First build
npm run build
# Then preview the built files
npm run preview

Could you clarify the specific use case this script is intended to address? This would help ensure we implement the most appropriate solution.

@codechirag123 codechirag123 added the deploy-pr For running PR environment label Dec 13, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
.github/workflows/build-preview-environment.yml (1)

72-72: Fix formatting: Add space after comma in job dependencies

The job dependencies list should have spaces after commas for better readability.

-needs: [deploy-dev-pr-environment,build-wf-service]
+needs: [deploy-dev-pr-environment, build-wf-service]
-needs: [deploy-dev-pr-environment,build-backoffice]
+needs: [deploy-dev-pr-environment, build-backoffice]
-needs: [deploy-dev-pr-environment,build-kyb]
+needs: [deploy-dev-pr-environment, build-kyb]

Also applies to: 83-83, 94-94

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 72-72: too few spaces after comma

(commas)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8657803 and 48fecb1.

📒 Files selected for processing (1)
  • .github/workflows/build-preview-environment.yml (3 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 72-72: too few spaces after comma

(commas)


[warning] 83-83: too few spaces after comma

(commas)


[warning] 94-94: too few spaces after comma

(commas)

🔇 Additional comments (5)
.github/workflows/build-preview-environment.yml (5)

14-16: LGTM: Permissions are correctly configured

The write permissions for contents, pull-requests, and packages are appropriate for the workflow's requirements of pushing Docker images and updating PR status.


69-69: LGTM: Improved Dockerfile configuration

The addition of the file parameter provides better flexibility in specifying different Dockerfiles for preview environments.

Also applies to: 80-80, 91-91, 102-102


Line range hint 104-127: LGTM: Well-implemented deploy preview trigger

The deploy preview implementation includes proper error handling, logging, and secure usage of tokens.

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 72-72: too few spaces after comma

(commas)


[warning] 83-83: too few spaces after comma

(commas)


[warning] 94-94: too few spaces after comma

(commas)


[warning] 105-105: too few spaces after comma

(commas)


[warning] 105-105: too few spaces after comma

(commas)


[warning] 105-105: too few spaces after comma

(commas)


[warning] 105-105: too few spaces after comma

(commas)


80-80: Verify the existence of preview Dockerfiles

Let's ensure that all required preview Dockerfiles exist in their respective locations.

Also applies to: 91-91, 102-102

✅ Verification successful

All required preview Dockerfiles are present

All the necessary Dockerfile.preview files exist in their expected locations:

  • apps/backoffice-v2/Dockerfile.preview
  • apps/kyb-app/Dockerfile.preview
  • apps/workflows-dashboard/Dockerfile.preview
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for the existence of preview Dockerfiles
files_to_check=(
  "apps/backoffice-v2/Dockerfile.preview"
  "apps/kyb-app/Dockerfile.preview"
  "apps/workflows-dashboard/Dockerfile.preview"
)

for file in "${files_to_check[@]}"; do
  if [ ! -f "$file" ]; then
    echo "Missing file: $file"
  fi
done

Length of output: 414


Script:

#!/bin/bash
# Let's use fd to find all Dockerfile.preview files in the repository
fd "Dockerfile.preview$"

Length of output: 140


23-23: Verify potential naming collisions with shortened environment names

The change from 8 to 7 characters for environment names could potentially increase the risk of naming collisions between different branches.

Let's analyze the potential impact:

Also applies to: 49-51

✅ Verification successful

After analyzing the workflow files and environment name generation logic, I can provide a definitive response regarding the potential naming collisions concern.

Environment naming scheme is safe from collisions

The environment naming implementation has several safeguards against collisions:

  • Branch names are sanitized by replacing "/" with "-"
  • The 7-character limit is applied after sanitization
  • The environment names are used in a concurrency group that includes the full branch ref
  • Each PR environment has its own isolated deployment through the concurrency group: "deploy-${{ github.event.pull_request.head.ref }}"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential naming collisions with 7-character prefixes
git branch -r | sed 's/origin\///' | while read branch; do
  prefix=$(echo "$branch" | tr "/" "-" | cut -c 1-7)
  echo "Branch: $branch, Prefix: $prefix"
done | sort -k3 | uniq -D -f2

Length of output: 311


Script:

#!/bin/bash
# Let's check the actual environment name generation logic in the workflow file
cat .github/workflows/build-preview-environment.yml

Length of output: 4777


Script:

#!/bin/bash
# Let's also check for any other workflow files that might be using similar environment naming patterns
fd -e yml -e yaml . .github/workflows/ --exec cat {}

Length of output: 66996


Script:

#!/bin/bash
# Let's check the git history to see if there were any past issues with environment names
git log --oneline -S "ENVIRONMENT_NAME" .github/workflows/

Length of output: 0

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (3)
.github/workflows/build-preview-environment.yml (2)

49-49: ⚠️ Potential issue

Revert branch name trimming to prevent naming conflicts

Reducing the branch name length to 7 characters increases the likelihood of naming conflicts in preview environments. This could lead to environment overwrites and deployment issues.

Apply this fix:

-          TRIMMED_BRANCH_NAME=$(echo -n "$SANITIZED_BRANCH_NAME" | cut -c 1-7)
+          TRIMMED_BRANCH_NAME=$(echo -n "$SANITIZED_BRANCH_NAME" | cut -c 1-8)

91-91: 🛠️ Refactor suggestion

Optimize preview Dockerfiles for development environments

The preview Dockerfiles should be optimized specifically for development environments.

Consider implementing:

  1. Multi-stage builds to reduce image size
  2. Development-specific configurations
  3. Preview-specific build arguments
  4. Standardized PATH environment variables

Also applies to: 102-102, 113-113

.github/workflows/build-push-docker-images.yml (1)

49-64: ⚠️ Potential issue

Fix security vulnerabilities in AWS secret handling

The current implementation has several security issues:

  1. Secrets are exposed in GitHub outputs and environment variables
  2. Secret ID is not properly quoted
  3. AWS credentials action version needs updating

Apply these fixes:

-        uses: aws-actions/configure-aws-credentials@v3
+        uses: aws-actions/configure-aws-credentials@v4
-          secret_value=$(aws secretsmanager get-secret-value --secret-id ${{ vars.PREVIEW_SECRET }} --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
-          echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_ENV
-          echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_OUTPUT
+          secret_value=$(aws secretsmanager get-secret-value --secret-id "${{ vars.PREVIEW_SECRET }}" --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
+          echo "SUBMODULE_SECRET=***" >> $GITHUB_ENV
+          echo "::add-mask::$secret_value"
+          echo "SUBMODULE_SECRET=$secret_value" >> "$GITHUB_OUTPUT"
🧰 Tools
🪛 actionlint (1.7.4)

51-51: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


60-60: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)


60-60: shellcheck reported issue in this script: SC2086:info:4:42: Double quote to prevent globbing and word splitting

(shellcheck)

🧹 Nitpick comments (2)
.github/workflows/build-preview-environment.yml (1)

83-83: Add spaces after commas in job dependencies

For better readability, add spaces after commas in the needs array.

Apply this formatting:

-    needs: [deploy-dev-pr-environment,build-wf-service-ee]
+    needs: [deploy-dev-pr-environment, build-wf-service-ee]

Also applies to: 94-94, 105-105, 116-116

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 83-83: too few spaces after comma

(commas)

.github/workflows/build-push-docker-images.yml (1)

166-166: Simplify build arguments conditional logic

The current build arguments use complex inline conditionals that are hard to read and maintain.

Consider refactoring to use a separate step for build arguments:

      - name: Set build arguments
        id: build-args
        run: |
          if [[ "${{ inputs.image_name }}" == "workflows-service" ]]; then
            echo "args=RELEASE=${{ steps.version.outputs.tag }},SHORT_SHA=${{ steps.version.outputs.sha_short }}" >> $GITHUB_OUTPUT
          elif [[ "${{ inputs.image_name }}" == "workflows-service-ee" ]]; then
            echo "args=BASE_IMAGE=ghcr.io/ballerine-io/workflows-service:${{ inputs.tag }}" >> $GITHUB_OUTPUT
          fi

      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          # ... other options ...
          build-args: ${{ steps.build-args.outputs.args }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb01b04 and fd5fc0c.

📒 Files selected for processing (2)
  • .github/workflows/build-preview-environment.yml (3 hunks)
  • .github/workflows/build-push-docker-images.yml (4 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 83-83: too few spaces after comma

(commas)


[warning] 94-94: too few spaces after comma

(commas)


[warning] 105-105: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)

.github/workflows/build-push-docker-images.yml

[error] 65-65: trailing spaces

(trailing-spaces)

🪛 actionlint (1.7.4)
.github/workflows/build-push-docker-images.yml

51-51: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


60-60: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)


60-60: shellcheck reported issue in this script: SC2086:info:4:42: Double quote to prevent globbing and word splitting

(shellcheck)


92-92: if: condition "${{ inputs.image_name }} == 'workflows-service'" is always evaluated to true because extra characters are around ${{ }}

(if-cond)

🔇 Additional comments (4)
.github/workflows/build-preview-environment.yml (2)

14-16: LGTM: Permissions are correctly configured

The write permissions for contents, pull-requests, and packages are appropriate for the workflow's operations.


60-70: Verify the impact of switching to EE service

The workflow now uses the Enterprise Edition service instead of the original workflow service. Please verify:

  1. That this change is intentional
  2. That all dependent services are compatible with the EE version

Also applies to: 71-80

✅ Verification successful

Switching to Enterprise Edition service is intentional and properly configured

Based on the workflow file analysis:

  • The change is intentional as all dependent services (backoffice, kyb, dashboard) are explicitly configured to depend on build-wf-service-ee job
  • The EE service is built using a dedicated Dockerfile (Dockerfile.ee) in the workflows-service directory
  • The change maintains the same interface with dependent services, just using the EE version instead
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for dependencies on the original workflow service
echo "Checking service dependencies:"
rg "workflows-service(?!-ee)" --type yaml

Length of output: 359


Script:

#!/bin/bash
# Check for dependencies on the original workflow service using a simpler pattern
echo "Checking service dependencies:"
rg "workflows-service" --type yaml -A 3

# Also check for any docker-compose references
echo -e "\nChecking docker-compose files:"
fd docker-compose | xargs cat

# Check for any k8s manifests that might reference the service
echo -e "\nChecking k8s manifests:"
fd -e yaml -e yml . k8s/ 2>/dev/null | xargs cat

Length of output: 13752


Script:

#!/bin/bash
# Let's check for any references to the EE version
echo "Checking EE service references:"
rg "workflows-service-ee" --type yaml -A 3

# Check the actual changes in the workflow file
echo -e "\nChecking the workflow file changes:"
cat .github/workflows/build-preview-environment.yml

Length of output: 5515

.github/workflows/build-push-docker-images.yml (2)

26-29: LGTM: File parameter is well-defined

The file input parameter is properly documented and marked as required, which ensures proper specification of Dockerfile paths.


95-103: Verify version management changes

The git tag retrieval logic is commented out, which could affect version consistency. Please verify:

  1. How versions will be managed without git tags
  2. The impact on existing version tracking
✅ Verification successful

Let me analyze the workflow service tags to understand the version management approach.


Based on the analysis of the workflow file and git tags, I can now provide a final response:

Version management is handled through GitHub Actions workflow

The commented out git tag retrieval logic has been replaced with a more robust version management system:

  1. The workflow now uses a custom GitHub Action (bump-version) to handle versioning
  2. Version information is passed through workflow inputs and metadata actions
  3. Docker image tags are managed via docker/metadata-action@v4
  4. Build args include RELEASE and SHORT_SHA for the workflow service image

The changes represent an improvement to the versioning system rather than a regression, as:

  • Version bumping is now handled by a dedicated action
  • The workflow supports both regular and EE (Enterprise Edition) versions
  • Version metadata is consistently applied across image builds
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check current version management
echo "Checking version tags:"
git fetch --tags origin
git tag -l "workflow-service@*" | sort -V

Length of output: 80235


Script:

#!/bin/bash
# Check the workflow file for version/tag references
echo "Checking workflow file for version references:"
cat .github/workflows/build-push-docker-images.yml

Length of output: 5975

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
services/workflows-service/package.json (1)

15-15: Add documentation for the preview environment setup.

Consider adding a comment in the package.json to document the purpose and requirements of the preview environment setup. This will help other developers understand when and how to use this script.

Add this documentation above the scripts section:

  "description": "workflow-service",
+ "scripts-documentation": {
+   "start:preview": "Prepares and starts the preview environment by running database migrations, data migrations, data sync, and starting the production server"
+ },
  "scripts": {
.github/workflows/build-preview-environment.yml (1)

116-116: Fix comma spacing in job dependencies

Add spaces after commas in the needs array for better readability:

-needs: [deploy-dev-pr-environment,build-wf-service,build-wf-service-ee,build-backoffice,build-kyb,build-dashboard]
+needs: [deploy-dev-pr-environment, build-wf-service, build-wf-service-ee, build-backoffice, build-kyb, build-dashboard]
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)

.github/workflows/build-push-docker-images.yml (1)

166-166: Simplify build arguments logic

The current implementation is hard to read with multiple conditions in a single line:

-            ${{ (inputs.image_name == 'workflows-service' && format('"RELEASE={0}"\n"SHORT_SHA={1}"', steps.version.outputs.tag, steps.version.outputs.sha_short)) || (inputs.image_name == 'workflows-service-ee' && format('"BASE_IMAGE=ghcr.io/ballerine-io/workflows-service:{0}"', inputs.tag)) || '' }}
+            ${{ inputs.image_name == 'workflows-service' && 
+                format('"RELEASE={0}"\n"SHORT_SHA={1}"', 
+                    steps.version.outputs.tag, 
+                    steps.version.outputs.sha_short) ||
+                inputs.image_name == 'workflows-service-ee' && 
+                format('"BASE_IMAGE=ghcr.io/ballerine-io/workflows-service:{0}"', 
+                    inputs.tag) || 
+                '' 
+            }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd5fc0c and 82e245a.

📒 Files selected for processing (3)
  • .github/workflows/build-preview-environment.yml (3 hunks)
  • .github/workflows/build-push-docker-images.yml (5 hunks)
  • services/workflows-service/package.json (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 72-72: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)


[warning] 116-116: too few spaces after comma

(commas)

.github/workflows/build-push-docker-images.yml

[error] 65-65: trailing spaces

(trailing-spaces)

🪛 actionlint (1.7.4)
.github/workflows/build-push-docker-images.yml

51-51: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


60-60: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)


60-60: shellcheck reported issue in this script: SC2086:info:4:42: Double quote to prevent globbing and word splitting

(shellcheck)


94-94: shellcheck reported issue in this script: SC2116:style:3:19: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'

(shellcheck)

🔇 Additional comments (7)
services/workflows-service/package.json (1)

15-15: LGTM! Verify the script dependencies.

The new start:preview script combines database migrations, data migrations, data sync, and production server start in the correct order. All required dependencies are present in the package.json.

Let's verify the dependencies for each command in the script:

✅ Verification successful

All required scripts and dependencies are present and properly configured

The verification confirms that:

  • All required scripts exist in package.json:
    • db:migrate-up uses Prisma for database migrations
    • db:data-migration:migrate builds and runs data migration scripts
    • db:data-sync runs data sync scripts
    • start:prod runs the production server
  • Required Prisma dependencies are present with matching versions:
    • prisma v4.16.2
    • @prisma/client v4.16.2
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence and usage of dependencies required by the start:preview script

# Check if all the required scripts exist
echo "Checking for required scripts..."
for script in "db:migrate-up" "db:data-migration:migrate" "db:data-sync" "start:prod"; do
  rg "\"$script\":" services/workflows-service/package.json
done

# Check for Prisma dependencies (required for migrations)
echo "Checking Prisma dependencies..."
rg "\"prisma\":" services/workflows-service/package.json
rg "\"@prisma/client\":" services/workflows-service/package.json

Length of output: 1241

.github/workflows/build-preview-environment.yml (4)

14-16: LGTM: Permissions are correctly configured

The write permissions are appropriately set for the workflow's requirements.


49-49: Revert branch name trimming to prevent naming conflicts

Reducing the branch name length to 7 characters increases the risk of naming conflicts in preview environments. This could lead to environment overwrites and deployment issues.


91-91: Preview Dockerfiles need optimization and standardization

The preview Dockerfiles should be optimized for preview environments.

Also applies to: 102-102, 113-113


71-80: Verify Dockerfile paths and dependencies

The workflow service EE job is well-structured with appropriate dependencies. Let's verify the Dockerfile paths exist:

✅ Verification successful

Dockerfile paths are correctly configured

Both required Dockerfile paths exist in the repository:

  • services/workflows-service/Dockerfile
  • services/workflows-service/Dockerfile.ee

The workflow job configuration is properly set up with the correct file paths and dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify Dockerfile paths exist
files=(
  "services/workflows-service/Dockerfile"
  "services/workflows-service/Dockerfile.ee"
)

for file in "${files[@]}"; do
  if [ -f "$file" ]; then
    echo "✓ Found $file"
  else
    echo "✗ Missing $file"
  fi
done

Length of output: 461

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 72-72: too few spaces after comma

(commas)

.github/workflows/build-push-docker-images.yml (2)

97-97: Incorrect tag pattern change needs to be reverted

The change from workflows-service@ to workflow-service@ breaks naming consistency.


61-64: ⚠️ Potential issue

Improve secret handling security

The current implementation exposes secrets in GitHub outputs and environment variables without proper masking:

-          echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_ENV
-          echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_OUTPUT
+          echo "::add-mask::$secret_value"
+          echo "SUBMODULE_SECRET=$secret_value" >> "$GITHUB_ENV"
+          echo "SUBMODULE_SECRET=***" >> "$GITHUB_OUTPUT"

Likely invalid or redundant comment.

run: git fetch --tags origin
- name: Configure AWS credentials
if: inputs.image_name == 'workflows-service-ee'
uses: aws-actions/configure-aws-credentials@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update AWS credentials action version

The current version of aws-actions/configure-aws-credentials is outdated:

-        uses: aws-actions/configure-aws-credentials@v3
+        uses: aws-actions/configure-aws-credentials@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: aws-actions/configure-aws-credentials@v3
uses: aws-actions/configure-aws-credentials@v4
🧰 Tools
🪛 actionlint (1.7.4)

51-51: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
.github/workflows/deploy-wf-service.yml (4)

Line range hint 22-24: Consider simplifying the SHORT_HASH environment variable logic

The current nested ternary expression is complex and hard to read. Consider refactoring to use a more explicit approach.

- SHORT_HASH: ${{ (inputs.environment == 'dev' && inputs.sha) || (inputs.environment == 'prod' && vars.SB_WF_SHORT_SHA) || (vars.DEV_WF_SHORT_SHA) }}
+ SHORT_HASH: ${{ 
+   inputs.environment == 'dev' 
+   && inputs.sha 
+   || inputs.environment == 'prod' 
+   && vars.SB_WF_SHORT_SHA 
+   || vars.DEV_WF_SHORT_SHA 
+ }}

Line range hint 155-162: Optimize Docker layer caching

The current cache configuration could be improved to reduce build times and resource usage.

Consider these optimizations:

  1. Use BuildKit's native caching instead of the actions/cache
  2. Implement cache versioning based on both Dockerfile and dependencies
- key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
+ key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package-lock.json', '**/yarn.lock') }}-v1

Line range hint 236-252: Enhance error handling in Helm chart updates

The current implementation doesn't explicitly handle potential failures in the YAML update process.

Consider adding error handling and validation:

  1. Validate the YAML structure before applying changes
  2. Add a post-update verification step
  3. Implement a rollback mechanism for failed updates

Line range hint 270-277: Enhance Slack notifications with more deployment details

The current Slack message could provide more valuable information to help track and debug deployments.

Consider adding:

  1. Link to the GitHub Actions run
  2. Deployment duration
  3. List of changed components
  4. Link to the commit that triggered the deployment
- slack-message: "Test Wf-service Deployment in ${{ inputs.environment }} with tag ${{ env.SHORT_HASH }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }} build result: ${{ job.status }}. successfully updated the wf-service helm values for ${{ inputs.environment }}."
+ slack-message: |
+   🚀 Wf-service Deployment Status
+   Environment: ${{ inputs.environment }}
+   Tag: ${{ env.SHORT_HASH }}-${{ needs.build-and-push-ee-image.outputs.SUBMODULE_SHORT_HASH }}-${{ inputs.environment }}
+   Result: ${{ job.status }}
+   Duration: ${{ steps.deploy-time.outputs.duration }}
+   
+   📦 Updated Components:
+   - Wf-service
+   - Prisma Migrate
+   - DB Migrate
+   - Data Sync
+   
+   🔗 Links:
+   - Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+   - Commit: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82e245a and 1ea4af7.

📒 Files selected for processing (1)
  • .github/workflows/deploy-wf-service.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/deploy-wf-service.yml (1)

114-114: Be aware of potential race conditions with the 'latest' tag

While adding the 'latest' tag for production deployments is a common practice, be cautious of potential race conditions if multiple production deployments occur simultaneously. The 'latest' tag might not always reflect the most recent deployment.

Consider implementing a deployment lock mechanism or verifying that your deployment process prevents concurrent production deployments.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
.github/workflows/build-preview-environment.yml (1)

49-49: ⚠️ Potential issue

Critical: Branch name trimming to 7 characters increases collision risk

As previously identified, reducing the branch name length to 7 characters significantly increases the risk of naming conflicts in preview environments. For example:

  • Branches "feature-123" and "feature-124" would both become "feature"
  • Branches "bal-2983" and "bal-2984" would both become "bal-298"

Recommendation: Maintain the previous 8-character length or implement a collision-safe naming strategy.

🧹 Nitpick comments (1)
.github/workflows/build-preview-environment.yml (1)

153-153: Improve readability of job dependencies

The comma-separated list of job dependencies could be more readable with proper spacing.

-    needs: [deploy-dev-pr-environment,build-wf-service,build-wf-service-ee,build-backoffice,build-kyb,build-dashboard,build-unified-api]
+    needs: [
+      deploy-dev-pr-environment,
+      build-wf-service,
+      build-wf-service-ee,
+      build-backoffice,
+      build-kyb,
+      build-dashboard,
+      build-unified-api
+    ]
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea4af7 and 71cbea4.

📒 Files selected for processing (1)
  • .github/workflows/build-preview-environment.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/build-preview-environment.yml

120-120: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


123-123: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


127-127: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


135-135: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting

(shellcheck)


135-135: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 72-72: too few spaces after comma

(commas)


[error] 114-114: trailing spaces

(trailing-spaces)


[error] 150-150: trailing spaces

(trailing-spaces)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)


[warning] 153-153: too few spaces after comma

(commas)

🔇 Additional comments (2)
.github/workflows/build-preview-environment.yml (2)

14-16: LGTM: Permissions are correctly configured for the workflow requirements

The elevated permissions are necessary for:

  • Pushing Docker images to GHCR
  • Updating PR status
  • Repository operations

23-23: LGTM: Added manual trigger support while maintaining label-based automation

The condition correctly handles both automated (PR label) and manual (workflow_dispatch) triggers.

Comment on lines +119 to +127
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update Docker-related action versions

The following actions have newer versions available:

  • docker/setup-buildx-action@v2
  • docker/setup-qemu-action@v2
  • aws-actions/configure-aws-credentials@v3

Update to the latest versions to ensure compatibility and security:

-        uses: docker/setup-buildx-action@v2
+        uses: docker/setup-buildx-action@v3
-        uses: docker/setup-qemu-action@v2
+        uses: docker/setup-qemu-action@v3
-        uses: aws-actions/configure-aws-credentials@v3
+        uses: aws-actions/configure-aws-credentials@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64,arm'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
🧰 Tools
🪛 actionlint (1.7.4)

120-120: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


123-123: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


127-127: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Comment on lines 149 to 150
docker pull ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest
docker tag ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:${{ needs.deploy-dev-pr-environment.outputs.env_name }}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for Docker operations

The Docker pull and tag commands lack error handling and proper formatting.

-          docker pull ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest
-          docker tag ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:${{ needs.deploy-dev-pr-environment.outputs.env_name }} 
+          if ! docker pull ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest; then
+            echo "Failed to pull latest image"
+            exit 1
+          fi
+          if ! docker tag ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest \
+            ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:${{ needs.deploy-dev-pr-environment.outputs.env_name }}; then
+            echo "Failed to tag image"
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker pull ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest
docker tag ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:${{ needs.deploy-dev-pr-environment.outputs.env_name }}
if ! docker pull ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest; then
echo "Failed to pull latest image"
exit 1
fi
if ! docker tag ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:latest \
ghcr.io/${{ github.repository_owner }}/${{ vars.UNIFIED_IMAGE_NAME }}:${{ needs.deploy-dev-pr-environment.outputs.env_name }}; then
echo "Failed to tag image"
exit 1
fi
🧰 Tools
🪛 yamllint (1.35.1)

[error] 150-150: trailing spaces

(trailing-spaces)

Comment on lines +135 to +138
run: |
secret_value=$(aws secretsmanager get-secret-value --secret-id ${{ vars.PREVIEW_SECRET }} --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_ENV
echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add quotes to prevent shell word splitting

The secret retrieval script should properly quote variables to prevent potential issues with special characters.

-          secret_value=$(aws secretsmanager get-secret-value --secret-id ${{ vars.PREVIEW_SECRET }} --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
+          secret_value=$(aws secretsmanager get-secret-value --secret-id "${{ vars.PREVIEW_SECRET }}" --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
-          echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_ENV
+          echo "SUBMODULE_SECRET=${secret_value}" >> "$GITHUB_ENV"
-          echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_OUTPUT
+          echo "SUBMODULE_SECRET=${secret_value}" >> "$GITHUB_OUTPUT"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
secret_value=$(aws secretsmanager get-secret-value --secret-id ${{ vars.PREVIEW_SECRET }} --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_ENV
echo "SUBMODULE_SECRET=$secret_value" >> $GITHUB_OUTPUT
run: |
secret_value=$(aws secretsmanager get-secret-value --secret-id "${{ vars.PREVIEW_SECRET }}" --query 'SecretString' --output text | jq -r '.SUBMODULE_SECRET')
echo "SUBMODULE_SECRET=${secret_value}" >> "$GITHUB_ENV"
echo "SUBMODULE_SECRET=${secret_value}" >> "$GITHUB_OUTPUT"
🧰 Tools
🪛 actionlint (1.7.4)

135-135: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting

(shellcheck)


135-135: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (4)
.github/workflows/build-preview-environment.yml (4)

49-49: ⚠️ Potential issue

Branch name trimming may cause naming conflicts

Reducing the branch name length to 7 characters increases the risk of naming conflicts in preview environments. This could lead to environment overwrites when branch names share the same first 7 characters.

Consider keeping the original 8-character length to reduce collision probability.


119-127: 🛠️ Refactor suggestion

Update Docker-related action versions

The following actions have newer versions available:

  • docker/setup-buildx-action@v2v3
  • docker/setup-qemu-action@v2v3
  • aws-actions/configure-aws-credentials@v3v4
🧰 Tools
🪛 actionlint (1.7.4)

120-120: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


123-123: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


127-127: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


135-138: ⚠️ Potential issue

Add quotes to prevent shell word splitting

Shell variables should be properly quoted to prevent word splitting issues.

🧰 Tools
🪛 actionlint (1.7.4)

135-135: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting

(shellcheck)


135-135: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)


149-151: 🛠️ Refactor suggestion

Add error handling for Docker operations

The Docker commands should include error handling and proper formatting.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 151-151: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71cbea4 and a2fa32c.

📒 Files selected for processing (1)
  • .github/workflows/build-preview-environment.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/build-preview-environment.yml

120-120: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


123-123: the runner of "docker/setup-qemu-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


127-127: the runner of "aws-actions/configure-aws-credentials@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


135-135: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting

(shellcheck)


135-135: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint (1.35.1)
.github/workflows/build-preview-environment.yml

[warning] 72-72: too few spaces after comma

(commas)


[error] 114-114: trailing spaces

(trailing-spaces)


[error] 151-151: trailing spaces

(trailing-spaces)


[warning] 154-154: too few spaces after comma

(commas)


[warning] 154-154: too few spaces after comma

(commas)


[warning] 154-154: too few spaces after comma

(commas)


[warning] 154-154: too few spaces after comma

(commas)


[warning] 154-154: too few spaces after comma

(commas)


[warning] 154-154: too few spaces after comma

(commas)

🔇 Additional comments (2)
.github/workflows/build-preview-environment.yml (2)

14-16: LGTM: Permissions are correctly configured

The elevated write permissions are necessary for:

  • Updating repository contents
  • Managing pull request statuses
  • Publishing container images to GitHub packages

23-23: LGTM: Job condition properly handles both trigger types

The condition correctly handles both manual triggers and labeled PRs.

Comment on lines +71 to +80
build-wf-service-ee:
needs: [deploy-dev-pr-environment,build-wf-service]
uses: ./.github/workflows/build-push-docker-images.yml
with:
registry: ghcr.io/${{ github.repository_owner }}
context: services/workflows-service
image_name: workflows-service-ee
ref: ${{ needs.deploy-dev-pr-environment.outputs.ref }}
tag: ${{ needs.deploy-dev-pr-environment.outputs.env_name }}
file: 'services/workflows-service/Dockerfile.ee'
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Dockerfile.ee needs to be updated with proper EE-specific configurations

The Dockerfile.ee appears to be incomplete compared to the base Dockerfile. While it exists at the correct location, it's missing critical configurations:

  • No multi-stage build setup (dev/prod stages)
  • Missing necessary dependencies installation (dumb-init)
  • Missing build steps and file copies
  • Missing environment variable configurations (RELEASE, SHORT_SHA)

The current EE Dockerfile seems to be just a minimal configuration that relies heavily on the BASE_IMAGE argument, but it should properly extend the base configuration with EE-specific additions.

🔗 Analysis chain

Verify the existence of Dockerfile.ee

Please verify that the Dockerfile.ee exists and contains the necessary EE-specific configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify Dockerfile.ee exists and contains EE-specific configurations
if [ -f "services/workflows-service/Dockerfile.ee" ]; then
  echo "✓ Found Dockerfile.ee"
  echo "Contents:"
  cat "services/workflows-service/Dockerfile.ee"
else
  echo "✗ Missing Dockerfile.ee"
fi

Length of output: 354


Script:

#!/bin/bash
# Let's verify if there's a non-EE Dockerfile to compare against
if [ -f "services/workflows-service/Dockerfile" ]; then
  echo "✓ Found base Dockerfile"
  echo "Contents of base Dockerfile:"
  cat "services/workflows-service/Dockerfile"
else
  echo "✗ Missing base Dockerfile"
fi

Length of output: 1181

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 72-72: too few spaces after comma

(commas)

@codechirag123 codechirag123 added deploy-pr For running PR environment and removed deploy-pr For running PR environment labels Dec 27, 2024
@codechirag123 codechirag123 added deploy-pr For running PR environment and removed deploy-pr For running PR environment labels Jan 2, 2025
@codechirag123 codechirag123 merged commit 0c32aab into dev Jan 3, 2025
27 of 28 checks passed
@codechirag123 codechirag123 deleted the dev-105/preview-githubaction branch January 3, 2025 13:27
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.

4 participants