next-right-now icon indicating copy to clipboard operation
next-right-now copied to clipboard

Refactor GHA workflows (reuse code)

Open Vadorequest opened this issue 2 years ago • 3 comments
trafficstars

Is your feature request related to a problem? Please describe. Some code is duplicated in the GHA workflows because we don't know how to reuse it.

Describe the solution you'd like See if https://github.com/actions/starter-workflows/issues/245#issuecomment-1445128447 could yield better solutions.

Vadorequest avatar Feb 25 '23 21:02 Vadorequest

Maybe it would be a good start to add general property "import" or "include" and possibly enable it to be either array or single value.

For instance: import: - some-file.yaml - some-other-file.yaml

or import: some-file.yaml

The logic behind should probably be equal to grabbing content and adding it to same level where the import is. I was also thinking to add possibility to include env files, but that should probably be separate property like "env-import".

for instance:

build:
  (...)
  import-env: ./some-file.env
  env:
    ENV-1: env-value
  (...)
  steps:
    - import: ./some-file-with-steps.yaml

This example would finally have env variables added to env from file in import-env and steps would contain all steps from file in import.

dxs0323 avatar Feb 14 '24 10:02 dxs0323

I'm not sure those options are actually being supported, we don't intend to change how YAML works.

Vadorequest avatar Feb 14 '24 10:02 Vadorequest

I think, the idea of reusability is probably impossible to implement without actually altering either yaml file or how yaml file is being processed. Maybe we do not need to copy/paste snippets and create another final yaml... maybe the only thing is to add some extra logic behind importing/including the other files. I am interested in this feature so I will be watching this feature regardless of the outcome.

dxs0323 avatar Feb 14 '24 11:02 dxs0323