Conditional pipeline uploads

I have this script to filters certain files when commited to not upload our pr-validation checks pipeline.
Originally, I wanted to run the script this way.
script.sh && buildkite-agent pipeline upload pipeline.yml

but in Buildkite UI, We are only allowed to use
buildkite-agent pipeline upload

I can do is create anotherpipeline.yml and call it in the Buildkite UI.

#anotherpipeline.yml
steps:
 - command: script.sh && buildkite-agent pipeline upload pipeline.yml

Is there a better way of doing this, I do not like to create anotherpipeline yml file with only one command step for the sake of running the script whether to upload the pipeline,yml

Hi @Joe, great question!

You should be able to run both script.sh and the pipeline upload in the steps defined in the UI.
Another option might be to have that script run as a hook.