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

Merged
merged 8 commits into from
Feb 10, 2025
Merged

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 manually with environment selection ('dev', 'sb', 'prod') or through external invocation.
    • Notifications are sent to Slack upon successful builds, indicating the environment used, and alerts are sent for build failures.
  • Chores

    • Setup of new workflow files for deployment automation.

Copy link

changeset-bot bot commented Dec 24, 2024

⚠️ No Changeset found

Latest commit: b05693b

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

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 manually and supports external invocation, allowing users to select an environment from predefined options. The workflows consist of 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/workflow on demand migration #2637: The changes in the main PR for the deploy-backoffice.yml workflow are related to the deploy-dashboard.yml workflow in the retrieved PR, as both introduce similar job structures and event triggers for GitHub Actions workflows, specifically focusing on build and Slack notification jobs.
  • Dev 105/preview githubaction #2879: The changes in the main PR for the deploy-backoffice.yml workflow are related to the deploy-dashboard.yml workflow in the retrieved PR, as both introduce similar job structures and functionalities for building and deploying applications, including the use of send-to-slack jobs and error handling mechanisms.
  • Dev 318/action alert delivery #2893: The changes in the main PR for the deploy-backoffice.yml workflow, specifically the addition of the send-to-slack job, are related to the send-to-slack job introduced in the retrieved PR for db-ops.yaml, as both jobs are designed to send notifications to a Slack channel upon successful completion of their respective workflows.

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
.github/workflows/deploy-dashboard.yml Outdated Show resolved Hide resolved
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)

.github/workflows/deploy-backoffice.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-backoffice.yml Show resolved Hide resolved
.github/workflows/deploy-backoffice.yml Outdated Show resolved Hide resolved
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.

.github/workflows/deploy-dashboard.yml Outdated Show resolved Hide resolved
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 (1)

21-28: 🛠️ Refactor suggestion

Update workflow_call input configuration for "environment".
The input is defined with both a default value ('dev') and marked as required, which makes the default value ineffective. To allow the default to be applied when no input is provided, set "required" to false.

Proposed diff:

-      environment:
-        type: string
-        description: 'Environment'
-        required: true
-        default: 'dev'
+      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)

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

21-28: 🛠️ Refactor suggestion

Update workflow_call input configuration for "environment".
Similar to the KYB workflow, the workflow_call input here is marked as required while also providing a default value. Changing "required" to false will let the default value ('dev') take effect when no input is provided.

Proposed diff:

-        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)

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

21-28: 🛠️ Refactor suggestion

Update workflow_call input configuration for "environment".
As with the other workflows, the "environment" input is set as required while also having a default value. To enable the default value to be used, adjust the input by setting "required" to false.

Proposed diff:

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

29-35: Maintain consistency and consider refactoring shared logic.
The workflow’s jobs (build, send-to-slack, on-failure) follow a pattern very similar to the other application workflows. For long-term maintainability, consider extracting the common webhook trigger and Slack notification steps into a reusable workflow. This flexible approach would reduce duplication.

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

81-82: Ensure a new line at end-of-file.
YAMLlint reports a missing new line at the end of the file. Adding a newline improves compatibility with various tools and editors.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

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


29-35: Consider consolidating repetitive workflow logic.
The build, send-to-slack, and on-failure jobs mirror those in the KYB and Backoffice workflows. Refactoring the shared logic into a reusable workflow file can ease maintenance and reduce duplication across your deployment pipelines.

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

81-82: Add a newline at the end of the file.
YAMLlint indicates that there is no new line at EOF, which can lead to issues with certain tooling. Please add a newline at the end.

🧰 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 fcc8821 and b05693b.

📒 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)

.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)

.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)

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

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

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

.github/workflows/deploy-dashboard.yml

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

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

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: spell_check
  • GitHub Check: lint
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: format
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.github/workflows/deploy-backoffice.yml (1)

29-35: Overall structure looks consistent.
The error handling in the webhook trigger and the branching logic for determining the environment are well implemented. Ensuring consistency with similar workflows is beneficial. Consider tracking common workflow patterns for future refactoring into a centralized reusable workflow.

@codechirag123 codechirag123 merged commit 130b240 into dev Feb 10, 2025
18 checks passed
@codechirag123 codechirag123 deleted the dev-336/amplify-webhook-builds branch February 10, 2025 10:08
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