Ensure that ONBUILD triggers aren't committed to grandchildren

This patch fixes the bug where ONBUILD triggers are committed each build
step created during the ONBUILD trigger execution, since the triggers are
only wiped *after* all ONBUILD trigger steps have been committed. This was
fixed by simply copying the ONBUILD triggers and wiping the config
*before* committing anything.

Fixes #6445.

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)

/cc @shykes
This test should be called `TestBuildOnBuildUnwantedInheritance` or something along those lines.

The test should also have a comment above it with the issue it fixes and what it's doing.
e.g.:
```// #6445 ensure ONBUILD triggers aren't committed to grand children```