amplify-hosting
amplify-hosting copied to clipboard
Wrong AWS_COMMIT_ID for webhook-triggered builds
Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the FAQ.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
App Id
NA
AWS Region
us-east-1
Amplify Hosting feature
Webhooks
Describe the bug
- When we deploy Amplify application by triggering build through web hook its displays "HEAD" as "Commit ID".
- AWS_COMMIT_ID = Commit ID = HEAD
- You may refer the attached screen-shot files.
Expected behavior
AWS_COMMIT_ID = Commit ID = GitHub Commit Hash
Reproduction steps
- create sample React App
- create private repository in GitHub and host all files, directories of React application.
- deploy Amplify app using GitHub CI/CD and by triggering build through web hook.
- check and verify "AWS_COMMIT_ID" for GitHub CI/CD and web hook triggered builds.
Build Settings
version: 1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- echo $AWS_COMMIT_ID
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- echo $AWS_COMMIT_ID
- npm ci
build:
commands:
- echo $AWS_COMMIT_ID
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Log output
# Put your logs below this line
Additional information
No response
Hi @shivennn 👋🏽 thanks for raising this question. We are looking into this behavior and will provide an update shortly.
This is expected behavior for builds triggered by webhooks. In the event that multiple webhooks are triggered for the same branch while a build is pending, we will deduplicate the webhook requests and build using the most recent request.
We will mark this as a feature request to surface the commit ID and commit message in the same way we do with CI/CD deployments.
This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!
As a workaround, you can get the real commit id during build from git. Instead of using AWS_COMMIT_ID:
---
frontend:
phases:
preBuild:
commands:
# get the real commit ID that we're building
- export GIT_COMMIT_ID=`git rev-parse --short $AWS_COMMIT_ID`
build:
commands:
# use the real commit ID that we got from git
- echo $GIT_COMMIT_ID
This will always give them a git sha. See these two examples:
❯ git rev-parse --short HEAD
20a9d35
❯ git rev-parse --short 20a9d35328795caf4ec644447bb535bde8d97874
20a9d35
@calavera Thanks for the workaround! +1 for this feature (commit sha being visible in the interface) and thank you to the team for making and managing the framework.
My thoughts: De-duplication of webhook requests is an implementation detail - and consequences of it shouldn't matter to the user. Using the actual SHA instead of a dynamic pointer that changes taints your build history because there is no way to know what was deployed (or without doing a lot of digging). Also re: de-duplication of webhook requests - if they're duplicates, shouldn't they be triggering a build of the same commit sha anyways, why is HEAD needed?