True GitOps and dynamic configuration with CircleCI

I would like to implement a GitOps process in which I bootstrap our system from scratch, including generating all system credentials and configuration parameters. These credentials and parameters need to be passed to further downstream builds (currently in other repos). We are using trunk-based development.

I am lost how to handle the dynamic parameters. My original idea was to generate contexts per feature branch and use these contexts for the downstream builds. However, there are a number of obstacles with this. It appears that contexts are assumed to be pre-defined before the build). There’s no real API to manage these outside of the CLI and setting contexts dynamically is also not easy, in particular computing their name based on branches.

I could potentially hack around with environment variables with some form of prefix based on the branch, but that looks neither easy nor elegant to me.

I was wondering if anyone here can shared some tips and best practices for such situations. Or is my use case outside of the scope of CircleCI?

Cheers and thanks,