aws-amplify / aws-amplify/amplify-hosting
postBuild script is running 30 seconds before actually finishing building
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-console/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-console/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-console/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### App Id
d3al4tzclcnvw3
### Region
us-west-2
### Amplify Console feature
Build settings
### Describe the bug
We are running a webhook on `postBuild` to invalidate a cloudfront cache, but notice it actually runs 30 seconds before the build time is actually finished (and assets are deployed). Therefor we can't properly time the invalidation.
Example. Today the invalidation webhook ran at 9:05:40 , but the build didnt actually finish until 9:06:10
Output from build (add this up and equals 9:06:10 - 30s after postBuild actually ran):
Started at 10/26/2021, 8:45:44 AM
Build duration 20 minutes 26 seconds
### Expected behavior
Run `postBuild` after the build is actually finished
### Reproduction steps
Rebuild master
Wait for `postBuild` step to run
Compare that to actual time it takes to finish and deploy assets
### Build Settings
```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run generate
postBuild:
commands:
- "curl -X POST -H 'Authorization: token ' --data '{\"event_type\": \"amplify_deploy\"}' https://api.github.com/repos///dispatches"
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```
### Additional information
_No response_
Contributor guide
Research direction
Start by reproducing the timing with the provided app, region, rebuild steps, and build settings. Compare the postBuild webhook timestamp with the actual asset deployment completion, then verify that the webhook runs only after deployment has finished.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, github, node.js
- Domain
- build-system, ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100