Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/cd-serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ jobs:
# --notices false \
# --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.
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
Comment on lines +59 to +63
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.

- name: Synth
env:
CDK_DEFAULT_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
Expand All @@ -62,7 +70,6 @@ jobs:
cdk synth \
--notices false \
--context env=prod \
--context imageTag="${{ github.event_name == 'workflow_run' && format('{0}-lambda', github.event.workflow_run.head_sha) || 'latest-lambda' }}" \
--ci \
--debug \
--verbose \
Expand Down Expand Up @@ -206,6 +213,14 @@ jobs:
force-skip-oidc: false
# action-timeout-s: 60

- 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: Deploy
env:
CDK_DEFAULT_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
Expand All @@ -214,7 +229,6 @@ jobs:
cdk deploy \
--notices false \
--context env=prod \
--context imageTag="${{ github.event_name == 'workflow_run' && format('{0}-lambda', github.event.workflow_run.head_sha) || 'latest-lambda' }}" \
--force \
--app dist \
--ci \
Expand Down
2 changes: 1 addition & 1 deletion serverless/configs/prod.context.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
imageUri: ghcr.io/zmynx/aws-lambda-calculator
imageTag: latest-lambda
imageTag: "2.1.1"
Loading