-
Notifications
You must be signed in to change notification settings - Fork 3
chore: configure GH Action to build AMI #1184
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
Conversation
WalkthroughAdds a STAGE workflow input (default: prod) to the AMI build GitHub Actions workflow; parameterizes stack names, CDK deploy commands, and CloudFormation queries to use AMI-Pipeline-${{ env.STAGE }}-Stack; conditionally makes the AMI public only for prod; and updates release notes to include stage and availability. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor GH as GitHub Actions Workflow
participant CDK as AWS CDK CLI
participant CFN as CloudFormation
participant EC2 as EC2 (AMI operations)
note over GH: Inputs.stage → env.STAGE (default: prod)
GH->>CDK: cdk deploy AMI-Pipeline-${STAGE}-Stack --context stage=${STAGE}
CDK->>CFN: Create/Update stack AMI-Pipeline-${STAGE}-Stack
CFN-->>CDK: Stack status + outputs
CDK-->>GH: Deployment result & outputs
GH->>CFN: aws cloudformation describe-stacks --stack-name AMI-Pipeline-${STAGE}-Stack
CFN-->>GH: Return outputs (AMI ID, etc.)
alt STAGE == prod
GH->>EC2: ModifyImageAttribute (make AMI public)
EC2-->>GH: Permission update + verification
else STAGE != prod
GH->>GH: Skip public AMI steps (AMI remains private)
end
GH->>GH: Create GitHub release notes (include Stage + availability)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
.github/workflows/ami-build.yml (4)
20-20: Consider making STAGE a workflow input parameter.The current approach requires editing the workflow file to change stages. This is error-prone and doesn't align with best practices for environment management.
Consider moving
STAGEto a workflow input parameter:workflow_dispatch: inputs: + stage: + description: "Deployment stage (prod or dev)" + type: choice + options: + - prod + - dev + default: prod force_build: description: "Force AMI build even if not a release" type: boolean default: falseThen reference it in the env section:
env: AWS_REGION: us-east-2 - STAGE: prod # Change to 'dev' for development AMIs + STAGE: ${{ github.event.inputs.stage || 'prod' }}
76-76: Optimize CDK bootstrap call.The
cdk bootstrapcommand runs unconditionally, which is redundant if the AWS environment is already bootstrapped. This adds unnecessary execution time.Consider checking bootstrap status before running:
- cdk bootstrap --require-approval never + # Check if already bootstrapped + if ! aws cloudformation describe-stacks \ + --stack-name CDKToolkit \ + --region "${{ env.AWS_REGION }}" > /dev/null 2>&1; then + echo "Bootstrapping CDK environment..." + cdk bootstrap --require-approval never + else + echo "CDK environment already bootstrapped." + fi
114-158: LGTM! Consider documenting timeout expectations.The polling logic and state handling are well-implemented. The 90-minute timeout is reasonable for AMI builds, but consider documenting typical build times in comments to help future maintainers understand if this value needs adjustment.
Consider adding a comment:
- name: Wait for AMI build completion - timeout-minutes: 90 + timeout-minutes: 90 # Typical AMI builds complete in 20-30 minutes
178-226: Consider including stage information in release notes.The release update adds AMI details but doesn't indicate which stage (prod/dev) the AMI was built for. This could be confusing if both stages are used.
Consider adding the stage to the release comment:
const amiId = process.env.AMI_ID; const region = process.env.AWS_REGION; + const stage = process.env.STAGE; const releaseId = process.env.RELEASE_ID; const comment = `## 🚀 AMI Build Completed + **Stage:** \`${stage}\` **AMI ID:** \`${amiId}\` **Region:** \`${region}\`
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/ami-build.yml(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build TrufNetwork AMI
- GitHub Check: acceptance-test
🔇 Additional comments (6)
.github/workflows/ami-build.yml (6)
90-94: LGTM!The logic correctly retrieves the pipeline ARN from the existing stack and makes it available to subsequent steps.
96-112: LGTM!The validation and error handling for the pipeline ARN is robust, and the ImageBuilder integration is correctly implemented.
160-176: LGTM!The AMI details summary provides comprehensive information for debugging and verification.
228-249: LGTM!The notification jobs provide clear feedback on workflow completion status.
48-69: Ensure CDK stack exportsAmiPipelineArnOutput
I couldn’t find aCfnOutputnamedAmiPipelineArnOutputin the CDK code underdeployments/infra; please add or confirm this output in theAMI-Pipeline-${{ env.STAGE }}-Stackso the workflow can retrieve the pipeline ARN.
76-79: Confirm CDK app reads and usesstagecontext
I searched forthis.node.tryGetContext('stage')andthis.node.getContext('stage')across the CDK code but found no matches. Ensure your CDK app code retrieves this context value (e.g., viathis.node.tryGetContext('stage')) and uses it to construct the stage-specific stack name.
Time Submission Status
|
resolves: https://github.com/trufnetwork/truf-network/issues/1246
currently testing: https://github.com/trufnetwork/node/actions/runs/18131563160/job/51599311887
Summary by CodeRabbit
New Features
Chores