aws-samples / aws-samples/aws-sam-github-actions-example
Action fails when there are no SAM changes
- 主要语言
- Python
- 星标
- 63
- 派生
- 40
- PR 合并指标
- 30 天内没有已合并 PR
描述
**Describe the bug**
When a change is pushed to main which doesn't update the SAM template, the deployment job will fail.
**To Reproduce**
Steps to reproduce the behavior:
The previous workflow must have completed successfully, and the repo hasn't been updated.
1. Go to Actions
2. Click on workflow "SAM Validate, Build, Test, Deploy"
3. Choose "Re-run jobs"
This job will fail
**Expected behavior**
The running job should succeed
**Screenshots**
Step "SAM deploy" fails with the following error:

(note that I ran this from my own fork, so the stack name is different to what you will expect)
A possible fix: Change the last command in template.yml to the following:
sam deploy --template-file .aws-sam/build/template.yaml \
--stack-name ${{ steps.vars.outputs.environment }} \
--s3-bucket ${{ steps.vars.outputs.environment }} \
--parameter-overrides \
'ParameterKey=Name,ParameterValue=example \
ParameterKey=Version,ParameterValue=${{ steps.vars.outputs.version }}' \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
|| echo "Nothing to deploy, no changes"
贡献指南
调研方向
从 template.yml 和“SAM Validate, Build, Test, Deploy”工作流开始,重点关注失败的“SAM deploy”步骤。通过在不更改 SAM template 的情况下重新运行一个已完成的工作流来重现该失败,然后验证在没有要部署的内容时,job 能够成功并报告没有部署更改。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- aws, github-actions
- 领域
- ci-cd, cloud, devops
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 38/100