Skip to content

Conversation

@zMynxx
Copy link
Contributor

@zMynxx zMynxx commented Oct 18, 2025

PR Type

Enhancement, Bug fix


Description

  • Replace inline context parameter with file-based configuration

  • Add workflow step to dynamically update context file with image tag

  • Remove hardcoded imageTag logic from CDK commands

  • Update prod.context.yaml with new version reference


Diagram Walkthrough

flowchart LR
  A["Workflow triggered"] --> B["Update context file<br/>with image tag"]
  B --> C["CDK Synth/Deploy<br/>reads from file"]
  D["Old: Inline context<br/>parameter"] -.-> E["New: File-based<br/>configuration"]
Loading

File Walkthrough

Relevant files
Enhancement
cd-serverless.yaml
Replace inline context with file-based configuration         

.github/workflows/cd-serverless.yaml

  • Add new workflow step to update prod.context.yaml with dynamic image
    tag before synth and deploy
  • Remove inline --context imageTag parameter from both CDK synth and
    deploy commands
  • Step runs conditionally when workflow_run succeeds and uses yq to
    update YAML file
  • Applied to both synth and deploy jobs for consistency
+16/-2   
Configuration changes
prod.context.yaml
Update image tag to version 2.1.1                                               

serverless/configs/prod.context.yaml

  • Update imageTag value from latest-lambda to 2.1.1
  • Maintains YAML structure with imageUri and imageTag fields
+1/-1     

Copilot AI review requested due to automatic review settings October 18, 2025 00:35
@zMynxx zMynxx merged commit 37aaec7 into main Oct 18, 2025
11 checks passed
@zMynxx zMynxx deleted the fix/context branch October 18, 2025 00:35
@codiumai-pr-agent-free
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->

</details></td></tr>
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how image tags are handled in the serverless deployment workflow by moving from inline context parameters to updating the context file at runtime.

  • Replaces inline --context imageTag parameters with runtime updates to the prod.context.yaml file
  • Adds new workflow steps to update the context file using yq before synth and deploy operations
  • Updates the default image tag in the context file from "latest-lambda" to "2.1.1"

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
serverless/configs/prod.context.yaml Updates default imageTag from "latest-lambda" to "2.1.1"
.github/workflows/cd-serverless.yaml Adds context file update steps and removes inline imageTag context parameters

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +59 to +63
working-directory: serverless/configs
env:
IMAGE_TAG: "${{ format('{0}-lambda', github.event.workflow_run.head_sha) }}"
run: |
yq -i '.imageTag = strenv(IMAGE_TAG)' prod.context.yaml
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The logic for updating the context file is duplicated between the synth job (lines 57-63) and deploy job (lines 216-222). Consider extracting this into a reusable composite action or workflow template to reduce code duplication and ensure consistency.

Suggested change
working-directory: serverless/configs
env:
IMAGE_TAG: "${{ format('{0}-lambda', github.event.workflow_run.head_sha) }}"
run: |
yq -i '.imageTag = strenv(IMAGE_TAG)' prod.context.yaml
uses: ./.github/actions/update-context-file
with:
image_tag: "${{ format('{0}-lambda', github.event.workflow_run.head_sha) }}"
context_file: "prod.context.yaml"
working_directory: "serverless/configs"

Copilot uses AI. Check for mistakes.
# --context env=prod

- name: Update context file with new version
if: ${{ github.event.workflow_run.conclusion == 'success' }}
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The condition checks github.event.workflow_run.conclusion == 'success' but this step runs before the actual deployment operations. If the workflow_run event doesn't exist or has a different conclusion, this step will be skipped and the context file won't be updated, potentially causing the deployment to use an outdated image tag.

Suggested change
if: ${{ github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Oct 18, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
565 552 98% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: d65f810 by action🐍

@github-actions
Copy link
Contributor

github-actions bot commented Oct 18, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  aws-lambda-calculator/src/aws_lambda_calculator
  calculator.py
Project Total  

This report was generated by python-coverage-comment-action

@codiumai-pr-agent-free
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle different workflow trigger types

Restore the fallback logic for non-workflow_run triggers (e.g., manual dispatch)
to use a default imageTag like latest-lambda. Adjust the if condition and
IMAGE_TAG environment variable to handle multiple trigger types.

.github/workflows/cd-serverless.yaml [57-63]

-+      - name: Update context file with new version
-+        if: ${{ github.event.workflow_run.conclusion == 'success' }}
-+        working-directory: serverless/configs
-+        env:
-+          IMAGE_TAG: "${{ format('{0}-lambda', github.event.workflow_run.head_sha) }}"
-+        run: |
-+          yq -i '.imageTag = strenv(IMAGE_TAG)' prod.context.yaml
+- name: Update context file with new version
+  if: github.event.workflow_run.conclusion == 'success' || github.event_name != 'workflow_run'
+  working-directory: serverless/configs
+  env:
+    IMAGE_TAG: "${{ github.event_name == 'workflow_run' && format('{0}-lambda', github.event.workflow_run.head_sha) || 'latest-lambda' }}"
+  run: |
+    yq -i '.imageTag = strenv(IMAGE_TAG)' prod.context.yaml

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a functional regression where the PR removes the fallback logic for manual triggers, causing them to fail or use a static tag. The proposed fix restores the original, more robust behavior.

Medium
High-level
Avoid redundant workflow step duplication

The "Update context file with new version" step is duplicated before the synth
and deploy commands. This suggestion proposes removing the second instance, as
the file update only needs to happen once per job.

Examples:

.github/workflows/cd-serverless.yaml [57-63]
      - name: Update context file with new version
        if: ${{ github.event.workflow_run.conclusion == 'success' }}
        working-directory: serverless/configs
        env:
          IMAGE_TAG: "${{ format('{0}-lambda', github.event.workflow_run.head_sha) }}"
        run: |
          yq -i '.imageTag = strenv(IMAGE_TAG)' prod.context.yaml
.github/workflows/cd-serverless.yaml [216-222]
      - name: Update context file with new version
        if: ${{ github.event.workflow_run.conclusion == 'success' }}
        working-directory: serverless/configs
        env:
          IMAGE_TAG: "${{ format('{0}-lambda', github.event.workflow_run.head_sha) }}"
        run: |
          yq -i '.imageTag = strenv(IMAGE_TAG)' prod.context.yaml

Solution Walkthrough:

Before:

jobs:
  deploy-prod:
    steps:
      - name: Update context file with new version
        run: yq -i '.imageTag = ...' prod.context.yaml

      - name: Synth
        run: cdk synth ...

      # ... other steps

      - name: Update context file with new version # Redundant step
        run: yq -i '.imageTag = ...' prod.context.yaml

      - name: Deploy
        run: cdk deploy ...

After:

jobs:
  deploy-prod:
    steps:
      - name: Update context file with new version
        run: yq -i '.imageTag = ...' prod.context.yaml

      - name: Synth
        run: cdk synth ...

      # ... other steps

      - name: Deploy
        run: cdk deploy ...
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a redundant step in the workflow, and removing it improves maintainability and adheres to the DRY principle without affecting functionality.

Low
  • More

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants