Hello,
Without getting into too much specifics, the way we used to construct conditional workflows are as follows: The condition is modelled as a stage in the pipeline A usually. The If-true is pipeline B and if-else is pipeline C.So you run your workflow and towards the end (on the last stage), you check the condition you want and if it's true trigger pipeline B, else pipeline C. You can use the APIs (or a simple cURL request to do that). This way you get all the benefits of using GoCD pipelines like better visibility, tracking, etc. To make identification easier, we also use the parent labels to track things better.
If you want any
(mutable) state to be persisted and/or be available as part of the pipeline or to its dependents, IMHO the best way is to write the state in a file (JSON/CSV/text YMMV) and expose it as an/many artifacts to be consumed later in the pipeline or fetch it in downstream for later consumption.
Thanks,