Hello people!
I'm using yml anchors in my pipelines already and wanted to clean it up even more.
Right now I've an anchor step like that:
- step: &build-frontend
name: Build application and generate artifacts
caches:
- node
script:
- echo $DOTENV_STAGING | base64 --decode > .env
- yarn
- yarn build
This step just builds my frontend code with a given .env file I have saved as base64 encoded string on my pipeline deployment variables.
The problem now is, I want to use the exact same step with a different variable on production as well, in that case it must be $DOTENV_PRODUCTION. How can I accomplish this somehow?
I know I could overwrite the whole step but then I also do not have to use the anchors. ;-)
What would also work is using the deployment name in an if condition but unfortunately it looks like there is no variable in the default variables where I can get it from?
I lost my mind for some reason and can't find any good solution.
Or maybe there is something more elegant?
Nice to hear from you!
Thanks.