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 336/amplify webhook builds #2906

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

codechirag123
Copy link
Collaborator

@codechirag123 codechirag123 commented Dec 24, 2024

New Actions for Amplify Applications to build manually

Summary by CodeRabbit

  • New Features

    • Introduced automated GitHub Actions workflows for building and deploying Backoffice, Dashboard, and KYB applications.
    • Each workflow can be triggered on pushes to the "dev" branch or manually with environment selection.
    • Notifications are sent to Slack upon successful builds, indicating the environment used.
  • Chores

    • Setup of new workflow files for deployment automation.

Copy link

changeset-bot bot commented Dec 24, 2024

⚠️ No Changeset found

Latest commit: 0010c56

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 24, 2024

Warning

Rate limit exceeded

@codechirag123 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fcc8821 and 0010c56.

📒 Files selected for processing (3)
  • .github/workflows/deploy-backoffice.yml (1 hunks)
  • .github/workflows/deploy-dashboard.yml (1 hunks)
  • .github/workflows/deploy-kyb.yml (1 hunks)

Walkthrough

This pull request introduces three new GitHub Actions workflow files (deploy-backoffice.yml, deploy-dashboard.yml, and deploy-kyb.yml) to automate build and deployment processes for different applications. Each workflow is designed to trigger builds on pushes to the "dev" branch for specific application paths, support manual triggering, and send Slack notifications upon successful build completion. The workflows share a consistent structure with three primary jobs: a build job that triggers a webhook, a send-to-slack job that notifies about the build status, and an on-failure job for failure notifications.

Changes

File Change Summary
.github/workflows/deploy-backoffice.yml New workflow for Backoffice application deployment with build, send-to-slack, and on-failure jobs
.github/workflows/deploy-dashboard.yml New workflow for Dashboard application deployment with build, send-to-slack, and on-failure jobs
.github/workflows/deploy-kyb.yml New workflow for KYB application deployment with build, send-to-slack, and on-failure jobs

Possibly related PRs

  • Dev 318/action alert delivery #2893: This PR modifies the alert delivery mechanism for the Slack notifications in the CI/CD process, which is directly related to the send-to-slack job introduced in the main PR's workflow.

Suggested reviewers

  • MayurDuduka
  • alonp99
  • liorzam

Poem

🐰 Workflows hop, deploy with glee
Builds trigger, secrets set us free
Slack alerts dance, notifications bright
Automation's magic takes flight tonight! 🚀


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: 4

🧹 Nitpick comments (3)
.github/workflows/deploy-kyb.yml (1)

49-51: Remove unnecessary permissions

The packages: write permission is not used in this job and should be removed.

    permissions:
      contents: read
-     packages: write
.github/workflows/deploy-backoffice.yml (2)

40-42: Enhance webhook payload with environment information

The webhook payload is empty but could include useful context about the build.

  - name: Trigger Build webhook
    run: |
-     curl -X POST -d {} "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" -H "Content-Type:application/json"
+     curl -X POST \
+       -d "{\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\"}" \
+       "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" \
+       -H "Content-Type:application/json"

58-59: Improve Slack message formatting

Consider using Slack's block kit for better message formatting and visibility.

  with:
    channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
-   slack-message: "Back-office Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
+   payload: |
+     {
+       "blocks": [
+         {
+           "type": "header",
+           "text": {
+             "type": "plain_text",
+             "text": "🏗️ Back-office Build Started"
+           }
+         },
+         {
+           "type": "section",
+           "fields": [
+             {
+               "type": "mrkdwn",
+               "text": "*Environment:*\n${{ github.event_name == 'push' && github.ref_name || inputs.environment }}"
+             },
+             {
+               "type": "mrkdwn",
+               "text": "*Triggered by:*\n${{ github.event_name }}"
+             }
+           ]
+         }
+       ]
+     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 246451b and c51f5bc.

📒 Files selected for processing (3)
  • .github/workflows/deploy-backoffice.yml (1 hunks)
  • .github/workflows/deploy-dashboard.yml (1 hunks)
  • .github/workflows/deploy-kyb.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/deploy-dashboard.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-kyb.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-backoffice.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-kyb.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-kyb.yml Show resolved Hide resolved
.github/workflows/deploy-kyb.yml Outdated Show resolved Hide resolved
Comment on lines 1 to 61
name: Under Testing - Build and Deploy Dashboard Application

on:
push:
paths:
# Run this pipeline only if there are changes in specified path
- 'apps/workflows-dashboard/**'
branches:
- "dev"
workflow_dispatch:
inputs:
environment:
type: choice
description: 'Choose Environment'
required: true
default: 'dev'
options:
- 'dev'
- 'sb'
- 'prod'
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: true
default: 'dev'

jobs:
build:
name: Build Dashboard App
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Trigger a webhook
- name: Trigger Build webhook
run: |
curl -X POST -d {} "${{ secrets.DASHBOARD_WEBHOOK_URL }}" -H "Content-Type:application/json"

send-to-slack:
runs-on: ubuntu-latest
needs: [build]
if: ${{ needs.build.result == 'success' }}
environment: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
permissions:
contents: read
packages: write

steps:
- name: Send alert to Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
slack-message: "Dashboard Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
env:
SLACK_BOT_TOKEN: ${{ secrets.ARGO_SLACK_BOT_TOKEN }}
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 reusable workflow pattern

All three workflows share identical structure and logic, differing only in application-specific values. Consider refactoring into a reusable workflow.

Create a new file .github/workflows/deploy-app.yml:

name: Deploy Application
on:
  workflow_call:
    inputs:
      app_name:
        type: string
        required: true
      app_path:
        type: string
        required: true
      environment:
        type: string
        required: false
        default: 'dev'
    secrets:
      webhook_url:
        required: true
      slack_channel_id:
        required: true
      slack_bot_token:
        required: true

jobs:
  build:
    name: Build ${{ inputs.app_name }}
    runs-on: ubuntu-latest
    environment: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
    steps:
      - uses: actions/checkout@v4
      - name: Trigger Build webhook
        run: |
          response=$(curl -s -w "\n%{http_code}" -X POST \
            -d "{\"app\":\"${{ inputs.app_name }}\",\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\"}" \
            "${{ secrets.webhook_url }}" \
            -H "Content-Type:application/json")
          status_code=$(echo "$response" | tail -n 1)
          if [ "$status_code" -lt 200 ] || [ "$status_code" -ge 300 ]; then
            echo "Error: Webhook request failed with status $status_code"
            echo "Response: $(echo "$response" | head -n -1)"
            exit 1
          fi

  send-to-slack:
    runs-on: ubuntu-latest
    needs: [build]
    if: ${{ needs.build.result == 'success' }}
    environment: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
    permissions:
      contents: read
    steps:
      - uses: slackapi/[email protected]
        with:
          channel-id: ${{ secrets.slack_channel_id }}
          payload: |
            {
              "blocks": [
                {
                  "type": "header",
                  "text": {
                    "type": "plain_text",
                    "text": "🏗️ ${{ inputs.app_name }} Build Started"
                  }
                },
                {
                  "type": "section",
                  "fields": [
                    {
                      "type": "mrkdwn",
                      "text": "*Environment:*\n${{ github.event_name == 'push' && github.ref_name || inputs.environment }}"
                    },
                    {
                      "type": "mrkdwn",
                      "text": "*Triggered by:*\n${{ github.event_name }}"
                    }
                  ]
                }
              ]
            }
        env:
          SLACK_BOT_TOKEN: ${{ secrets.slack_bot_token }}

Then simplify each app-specific workflow to:

name: Under Testing - Build and Deploy Dashboard Application
on:
  push:
    paths:
      - 'apps/workflows-dashboard/**'
    branches:
      - "dev"
  workflow_dispatch:
    inputs:
      environment:
        type: choice
        description: 'Choose Environment'
        required: true
        default: 'dev'
        options: ['dev', 'sb', 'prod']

jobs:
  deploy:
    uses: ./.github/workflows/deploy-app.yml
    with:
      app_name: 'Dashboard'
      app_path: 'apps/workflows-dashboard'
      environment: ${{ inputs.environment }}
    secrets:
      webhook_url: ${{ secrets.DASHBOARD_WEBHOOK_URL }}
      slack_channel_id: ${{ secrets.ARGO_SLACK_CHANNEL_ID }}
      slack_bot_token: ${{ secrets.ARGO_SLACK_BOT_TOKEN }}
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


37-37: the runner of "actions/checkout@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: 3

♻️ Duplicate comments (5)
.github/workflows/deploy-kyb.yml (4)

22-27: ⚠️ Potential issue

Fix workflow_call input configuration

The environment input is marked as both required and has a default value, which is contradictory. The default value will never be used if the input is required.

Apply this diff to fix the configuration:

  workflow_call:
    inputs:
      environment:
        type: string
        description: 'Environment'
-       required: true
-       default: 'dev'
+       required: false
+       default: 'dev'
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


36-37: ⚠️ Potential issue

Update actions/checkout to the latest version

The current version (@V3) is outdated. Update to the latest stable version for security fixes and improvements.

- uses: actions/checkout@v3
+ uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

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

(action)


40-42: ⚠️ Potential issue

Add error handling to webhook trigger

The current webhook implementation lacks error handling and validation. Consider adding proper error handling and response validation.

  - name: Trigger Build webhook
    run: |
-     curl -X POST -d {} "${{ secrets.KYB_WEBHOOK_URL }}" -H "Content-Type:application/json"
+     response=$(curl -s -w "\n%{http_code}" -X POST -d {} "${{ secrets.KYB_WEBHOOK_URL }}" -H "Content-Type:application/json")
+     status_code=$(echo "$response" | tail -n 1)
+     if [ "$status_code" -lt 200 ] || [ "$status_code" -ge 300 ]; then
+       echo "Error: Webhook request failed with status $status_code"
+       echo "Response: $(echo "$response" | head -n -1)"
+       exit 1
+     fi

1-79: 🛠️ Refactor suggestion

Consider implementing reusable workflow pattern

All three workflows share identical structure and logic, differing only in application-specific values. Consider refactoring into a reusable workflow.

Create a new file .github/workflows/deploy-app.yml with a reusable workflow pattern that accepts application-specific inputs and secrets. Then simplify each app-specific workflow to use the reusable workflow. This will:

  • Reduce code duplication
  • Centralize maintenance
  • Ensure consistent behavior across applications
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-backoffice.yml (1)

1-79: 🛠️ Refactor suggestion

Implement reusable workflow pattern

This workflow shares identical structure with deploy-dashboard.yml. Consider refactoring into a reusable workflow to reduce duplication and improve maintainability.

See the previous review comment for detailed implementation of the reusable workflow pattern.

🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

🪛 yamllint (1.35.1)

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 79-79: no new line character at the end of file

(new-line-at-end-of-file)

🧹 Nitpick comments (2)
.github/workflows/deploy-backoffice.yml (2)

49-51: Remove unnecessary permissions

The packages:write permission is not required for sending Slack notifications.

    permissions:
      contents: read
-     packages: write

54-61: Enhance Slack notifications with rich formatting

The current Slack messages are basic text. Consider using Slack's block kit for better formatting and more context.

  - name: Send alert to Slack channel
    id: slack
    uses: slackapi/[email protected]
    with:
      channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
-     slack-message: "Back-office Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
+     payload: |
+       {
+         "blocks": [
+           {
+             "type": "header",
+             "text": {
+               "type": "plain_text",
+               "text": "🏗️ Back-office Build Started"
+             }
+           },
+           {
+             "type": "section",
+             "fields": [
+               {
+                 "type": "mrkdwn",
+                 "text": "*Environment:*\n${{ github.event_name == 'push' && github.ref_name || inputs.environment }}"
+               },
+               {
+                 "type": "mrkdwn",
+                 "text": "*Triggered by:*\n${{ github.event_name }}"
+               }
+             ]
+           }
+         ]
+       }
    env:
      SLACK_BOT_TOKEN: ${{ secrets.ARGO_SLACK_BOT_TOKEN }}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c51f5bc and 2820d9d.

📒 Files selected for processing (3)
  • .github/workflows/deploy-backoffice.yml (1 hunks)
  • .github/workflows/deploy-dashboard.yml (1 hunks)
  • .github/workflows/deploy-kyb.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/deploy-kyb.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-dashboard.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-backoffice.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

🪛 yamllint (1.35.1)
.github/workflows/deploy-dashboard.yml

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 79-79: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/deploy-backoffice.yml

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 79-79: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/deploy-dashboard.yml (1)

1-79: Address identical issues as in deploy-backoffice.yml

This workflow has the same issues as identified in deploy-backoffice.yml:

  1. Workflow_call input configuration
  2. Outdated checkout action
  3. Basic webhook implementation
  4. Unnecessary permissions
  5. Basic Slack notifications
  6. Need for reusable workflow pattern

Please apply the same fixes as suggested for deploy-backoffice.yml.

🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

🪛 yamllint (1.35.1)

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 79-79: no new line character at the end of file

(new-line-at-end-of-file)

Comment on lines 36 to 37
- name: Checkout code
uses: actions/checkout@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 actions/checkout to latest version

The checkout action version v3 is outdated. Update to the latest version for security and performance improvements.

- uses: actions/checkout@v3
+ uses: actions/checkout@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: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

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

(action)

Comment on lines +21 to +27
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: true
default: 'dev'
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 workflow_call input configuration

The environment input in the workflow_call event is marked as both required and has a default value. This is redundant as the default value will never be used when the input is required.

Apply this fix:

  workflow_call:
    inputs:
      environment:
        type: string
        description: 'Environment'
-       required: true
-       default: 'dev'
+       required: false
+       default: 'dev'
📝 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
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: true
default: 'dev'
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: false
default: 'dev'
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

Comment on lines 40 to 42
- name: Trigger Build webhook
run: |
curl -X POST -d {} "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" -H "Content-Type:application/json"
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

Enhance webhook call with proper error handling and payload

The current webhook implementation has several issues:

  1. No error handling for failed requests
  2. Empty payload doesn't provide context about the build
  3. No verification of webhook response
  - name: Trigger Build webhook
    run: |
-     curl -X POST -d {} "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" -H "Content-Type:application/json"
+     response=$(curl -s -w "\n%{http_code}" -X POST \
+       -d "{\"app\":\"backoffice\",\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\"}" \
+       "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" \
+       -H "Content-Type:application/json")
+     status_code=$(echo "$response" | tail -n 1)
+     if [ "$status_code" -lt 200 ] || [ "$status_code" -ge 300 ]; then
+       echo "Error: Webhook request failed with status $status_code"
+       echo "Response: $(echo "$response" | head -n -1)"
+       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
- name: Trigger Build webhook
run: |
curl -X POST -d {} "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" -H "Content-Type:application/json"
- name: Trigger Build webhook
run: |
response=$(curl -s -w "\n%{http_code}" -X POST \
-d "{\"app\":\"backoffice\",\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\"}" \
"${{ secrets.BACKOFFICE_WEBHOOK_URL }}" \
-H "Content-Type:application/json")
status_code=$(echo "$response" | tail -n 1)
if [ "$status_code" -lt 200 ] || [ "$status_code" -ge 300 ]; then
echo "Error: Webhook request failed with status $status_code"
echo "Response: $(echo "$response" | head -n -1)"
exit 1
fi

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/deploy-kyb.yml (3)

21-27: ⚠️ Potential issue

Fix contradictory workflow_call input configuration

The environment input is marked as both required and has a default value, which is contradictory as the default value will never be used.

Apply this fix:

  workflow_call:
    inputs:
      environment:
        type: string
        description: 'Environment'
-       required: true
-       default: 'dev'
+       required: false
+       default: 'dev'
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


36-37: ⚠️ Potential issue

Update actions/checkout to the latest version

The current version (@V3) is outdated. Update to the latest stable version for security fixes and improvements.

- uses: actions/checkout@v3
+ uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.4)

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

(action)


1-86: 🛠️ Refactor suggestion

Consider implementing reusable workflow pattern

All three workflows share identical structure and logic, differing only in application-specific values. Consider refactoring into a reusable workflow to improve maintainability and reduce duplication.

Create a new file .github/workflows/deploy-app.yml that accepts app-specific parameters. Then simplify each app-specific workflow to call this reusable workflow. Would you like me to provide the implementation details for this refactoring?

🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

🧹 Nitpick comments (2)
.github/workflows/deploy-kyb.yml (1)

41-49: Enhance webhook payload with build context

While error handling is implemented correctly, the webhook payload is empty and doesn't provide context about the build.

  - name: Trigger Build webhook
    run: |
      response=$(curl -s -w "\n%{http_code}" -X POST \
-       -d {} \
+       -d "{\"app\":\"kyb\",\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\"}" \
        "${{ secrets.KYB_WEBHOOK_URL }}" \
        -H "Content-Type:application/json")
.github/workflows/deploy-backoffice.yml (1)

66-66: Maintain consistent naming convention in Slack messages

The application name is inconsistently formatted in Slack messages:

  • Line 66: "Back-office"
  • Line 84: "Backoffice"

Standardize the naming across all messages.

-         slack-message: "Back-office Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
+         slack-message: "Backoffice Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."

Also applies to: 84-84

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2820d9d and 019ce38.

📒 Files selected for processing (3)
  • .github/workflows/deploy-backoffice.yml (1 hunks)
  • .github/workflows/deploy-dashboard.yml (1 hunks)
  • .github/workflows/deploy-kyb.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/deploy-backoffice.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-kyb.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

.github/workflows/deploy-dashboard.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

🪛 yamllint (1.35.1)
.github/workflows/deploy-backoffice.yml

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 86-86: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/deploy-dashboard.yml

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 86-86: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/deploy-dashboard.yml (1)

1-86: Review completed

The issues found in this file are identical to those in deploy-kyb.yml. Please apply the same fixes suggested in the previous review comments.

🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


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

(action)

🪛 yamllint (1.35.1)

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 86-86: no new line character at the end of file

(new-line-at-end-of-file)

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 (1)
.github/workflows/deploy-kyb.yml (1)

22-27: ⚠️ Potential issue

Fix contradictory workflow_call input configuration

The environment input is marked as both required and has a default value, which is contradictory as the default value will never be used.

  workflow_call:
    inputs:
      environment:
        type: string
        description: 'Environment'
-       required: true
-       default: 'dev'
+       required: false
+       default: 'dev'
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

🧹 Nitpick comments (8)
.github/workflows/deploy-kyb.yml (2)

52-54: Optimize job permissions

The jobs only need Slack notifications functionality but have additional permissions:

  • contents: read - Not needed for Slack notifications
  • packages: write - Not needed for Slack notifications

Consider removing unnecessary permissions to follow the principle of least privilege.

    permissions:
-     contents: read
-     packages: write

Also applies to: 71-73


61-62: Enhance Slack notifications with more context

The current Slack messages could be more informative by including:

  • The PR/commit that triggered the build
  • Link to the GitHub Actions run
  • Build duration (for success message)
-         slack-message: "KYB Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
+         slack-message: |
+           KYB Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
+           Trigger: ${{ github.event_name == 'push' && format('Commit {0}', github.sha) || 'Manual trigger' }}
+           Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

Also applies to: 79-80

.github/workflows/deploy-backoffice.yml (4)

1-1: Clarify the testing status in the workflow name

The workflow name includes "Under Testing" which might cause confusion. Consider either:

  1. Removing "Under Testing" if the workflow is ready for production
  2. Adding a comment explaining what aspects are being tested
-name: Under Testing - Build and Deploy Backoffice Application
+name: Build and Deploy Backoffice Application

5-7: Consider making the path filter more specific

The current path filter includes all files under apps/backoffice-v2/**. Consider making it more specific to only trigger on relevant file changes (e.g., excluding test files or documentation).

  paths:
    # Run this pipeline only if there are changes in specified path
-   - 'apps/backoffice-v2/**'
+   - 'apps/backoffice-v2/src/**'
+   - 'apps/backoffice-v2/package.json'
+   - 'apps/backoffice-v2/package-lock.json'

33-33: Refactor repeated environment determination logic

The environment determination logic ${{ github.event_name == 'push' && github.ref_name || inputs.environment }} is repeated across multiple jobs. Consider using a job output or environment variable to maintain DRY principles.

jobs:
+ set-environment:
+   runs-on: ubuntu-latest
+   outputs:
+     env_name: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
+   steps:
+     - run: echo "Setting environment"

  build:
    name: Build Backoffice App
+   needs: [set-environment]
    runs-on: ubuntu-latest
-   environment: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
+   environment: ${{ needs.set-environment.outputs.env_name }}

Also applies to: 51-51, 70-70


47-82: Optimize Slack notification jobs

Consider the following improvements:

  1. Consolidate duplicate Slack notification logic into a reusable workflow
  2. Add timeout configuration to prevent long-running jobs
  3. Add concurrency configuration to prevent multiple builds for the same environment
+ concurrency:
+   group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
+   cancel-in-progress: true

  jobs:
    build:
+     timeout-minutes: 10

+   notify-slack:
+     runs-on: ubuntu-latest
+     needs: [build]
+     if: always()
+     environment: ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}
+     permissions:
+       contents: read
+       packages: write
+     steps:
+       - name: Send alert to Slack channel
+         id: slack
+         uses: slackapi/[email protected]
+         with:
+           channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
+           slack-message: "Back-office Build ${{ needs.build.result == 'success' && 'initialized' || 'failed' }} in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
+         env:
+           SLACK_BOT_TOKEN: ${{ secrets.ARGO_SLACK_BOT_TOKEN }}

-   send-to-slack:
-     # Remove duplicate job
-   on-failure:
-     # Remove duplicate job
🧰 Tools
🪛 yamllint (1.35.1)

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/deploy-dashboard.yml (2)

52-55: Remove unnecessary permissions

Both Slack notification jobs include packages: write permission which is not required for sending Slack messages.

Remove the unnecessary permission:

     permissions:
       contents: read
-      packages: write

Also applies to: 71-74


47-82: Enhance Slack notifications with rich formatting

The current Slack messages are basic text. Consider using block kit formatting to provide richer, more informative notifications.

Replace both Slack notification steps with this enhanced version:

       - name: Send alert to Slack channel
         id: slack
         uses: slackapi/[email protected]
         with:
           channel-id: '${{ secrets.ARGO_SLACK_CHANNEL_ID }}'
-          slack-message: "Dashboard Build initialized in ${{ github.event_name == 'push' && github.ref_name || inputs.environment }}."
+          payload: |
+            {
+              "blocks": [
+                {
+                  "type": "header",
+                  "text": {
+                    "type": "plain_text",
+                    "text": "🏗️ Dashboard Build ${{ job.status == 'success' && 'Started' || 'Failed' }}"
+                  }
+                },
+                {
+                  "type": "section",
+                  "fields": [
+                    {
+                      "type": "mrkdwn",
+                      "text": "*Environment:*\n${{ github.event_name == 'push' && github.ref_name || inputs.environment }}"
+                    },
+                    {
+                      "type": "mrkdwn",
+                      "text": "*Triggered by:*\n${{ github.event_name }}"
+                    }
+                  ]
+                }
+              ]
+            }

Also, consider consolidating both Slack notification jobs into a single reusable job to reduce code duplication.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 019ce38 and fcc8821.

📒 Files selected for processing (3)
  • .github/workflows/deploy-backoffice.yml (1 hunks)
  • .github/workflows/deploy-dashboard.yml (1 hunks)
  • .github/workflows/deploy-kyb.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/deploy-kyb.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

.github/workflows/deploy-backoffice.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

.github/workflows/deploy-dashboard.yml

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

🪛 yamllint (1.35.1)
.github/workflows/deploy-backoffice.yml

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/deploy-dashboard.yml

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (6)
.github/workflows/deploy-kyb.yml (2)

1-1: Clarify the testing status in the workflow name

The workflow name includes "Under Testing" - is this intended for production use? Consider removing this prefix once testing is complete.


34-45: 🛠️ Refactor suggestion

Add repository checkout step

The build job is missing the checkout step which might be needed for accessing repository contents.

    steps:
+     - name: Checkout
+       uses: actions/checkout@v4
      # Trigger a webhook
      - name: Trigger Build webhook

Likely invalid or redundant comment.

.github/workflows/deploy-backoffice.yml (2)

21-27: Fix workflow_call input configuration

The environment input in the workflow_call event is marked as both required and has a default value. This is redundant as the default value will never be used when the input is required.

  workflow_call:
    inputs:
      environment:
        type: string
        description: 'Environment'
-       required: true
-       default: 'dev'
+       required: false
+       default: 'dev'
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)


36-45: Enhance webhook implementation

The current webhook implementation can be improved in several ways:

  1. Add proper request headers for authentication
  2. Include meaningful payload with build context
  3. Add retry mechanism for transient failures
  - name: Trigger Build webhook
    run: |
+     MAX_RETRIES=3
+     retry_count=0
+     while [ $retry_count -lt $MAX_RETRIES ]; do
      response=$(curl -s -w "\n%{http_code}" -X POST \
-       -d {} \
+       -d "{\"app\":\"backoffice\",\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\",\"sha\":\"${{ github.sha }}\"}" \
        "${{ secrets.BACKOFFICE_WEBHOOK_URL }}" \
-       -H "Content-Type:application/json"
+       -H "Content-Type:application/json" \
+       -H "X-GitHub-Event: ${{ github.event_name }}" \
+       -H "X-Hub-Signature: ${{ github.sha }}"
      status_code=$(echo "$response" | tail -n 1)
      if [ "$status_code" -lt 200 ] || [ "$status_code" -ge 300 ]; then
+       retry_count=$((retry_count + 1))
+       if [ $retry_count -lt $MAX_RETRIES ]; then
+         echo "Attempt $retry_count failed. Retrying in 5 seconds..."
+         sleep 5
+         continue
+       fi
        echo "Error: Webhook request failed with status $status_code"
        echo "Response: $(echo "$response" | head -n -1)"
        exit 1
      fi
+     break
+     done
.github/workflows/deploy-dashboard.yml (2)

1-82: Consider implementing reusable workflow pattern

As suggested in a previous review, all three workflows (dashboard, backoffice, and kyb) share identical structure and logic. Consider refactoring into a reusable workflow to improve maintainability.

The previous review provided a detailed implementation suggestion for creating a reusable workflow pattern. Please refer to that comment for the implementation details.

🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

🪛 yamllint (1.35.1)

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)


[error] 82-82: no new line character at the end of file

(new-line-at-end-of-file)


36-45: 🛠️ Refactor suggestion

Enhance webhook payload with build context

The webhook request is sent with an empty payload (-d {}), which misses important context about the build. Consider including relevant information such as:

  • Environment
  • Trigger source (push/manual)
  • Repository information
  • Branch/commit details

Apply this diff to enhance the webhook payload:

       - name: Trigger Build webhook
         run: |
-          response=$(curl -s -w "\n%{http_code}" -X POST -d {} "${{ secrets.DASHBOARD_WEBHOOK_URL }}" -H "Content-Type:application/json")
+          response=$(curl -s -w "\n%{http_code}" -X POST \
+            -d "{\"app\":\"dashboard\",\"environment\":\"${{ github.event_name == 'push' && github.ref_name || inputs.environment }}\",\"trigger\":\"${{ github.event_name }}\",\"repo\":\"${{ github.repository }}\",\"ref\":\"${{ github.ref }}\"}" \
+            "${{ secrets.DASHBOARD_WEBHOOK_URL }}" \
+            -H "Content-Type:application/json")
           status_code=$(echo "$response" | tail -n 1)
           if [ "$status_code" -lt 200 ] || [ "$status_code" -ge 300 ]; then
             echo "Error: Webhook request failed with status $status_code"

Likely invalid or redundant comment.

Comment on lines 3 to 28
on:
push:
paths:
# Run this pipeline only if there are changes in specified path
- 'apps/workflows-dashboard/**'
branches:
- "dev"
workflow_dispatch:
inputs:
environment:
type: choice
description: 'Choose Environment'
required: true
default: 'dev'
options:
- 'dev'
- 'sb'
- 'prod'
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: true
default: 'dev'

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 workflow trigger configuration issues

There are several issues in the workflow trigger configuration:

  1. The environment input in workflow_call is marked as both required and has a default value, which is redundant.
  2. Environment configuration is inconsistent between workflow_dispatch and workflow_call.
  3. Branch indentation is incorrect.

Apply this diff to fix the issues:

 on:
   push:
     paths:
       # Run this pipeline only if there are changes in specified path
       - 'apps/workflows-dashboard/**'
     branches:
-    - "dev"
+      - "dev"
   workflow_dispatch:
     inputs:
       environment:
         type: choice
         description: 'Choose Environment'
         required: true
         default: 'dev'
         options:
           - 'dev'
           - 'sb'
           - 'prod'
   workflow_call:
     inputs:
       environment:
         type: string
         description: 'Environment'
-        required: true
-        default: 'dev'
+        required: false
+        default: 'dev'
+        enum: ['dev', 'sb', 'prod']
📝 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
on:
push:
paths:
# Run this pipeline only if there are changes in specified path
- 'apps/workflows-dashboard/**'
branches:
- "dev"
workflow_dispatch:
inputs:
environment:
type: choice
description: 'Choose Environment'
required: true
default: 'dev'
options:
- 'dev'
- 'sb'
- 'prod'
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: true
default: 'dev'
on:
push:
paths:
# Run this pipeline only if there are changes in specified path
- 'apps/workflows-dashboard/**'
branches:
- "dev"
workflow_dispatch:
inputs:
environment:
type: choice
description: 'Choose Environment'
required: true
default: 'dev'
options:
- 'dev'
- 'sb'
- 'prod'
workflow_call:
inputs:
environment:
type: string
description: 'Environment'
required: false
default: 'dev'
enum: ['dev', 'sb', 'prod']
🧰 Tools
🪛 actionlint (1.7.4)

27-27: input "environment" of workflow_call event has the default value "dev", but it is also required. if an input is marked as required, its default value will never be used

(events)

🪛 yamllint (1.35.1)

[warning] 9-9: wrong indentation: expected 6 but found 4

(indentation)

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.

2 participants