Wandalen / wretry.action

Retry action for Github CI
MIT License
93 stars 20 forks source link

Take action string and inputs from another step #166

Closed Vampire closed 1 month ago

Vampire commented 1 month ago

I have no idea whether it is possible, but it would be nice if you could take the action string and input map from another step in the workflow.

I'm usually using typesafegithub/github-workflows-kt for writing the workflow files.

If you use this action you loose the type-safety and guidance of the library when writing the workflow file.

It would be nice if I could do something like:

val setupJava11 = uses(
    name = "Setup Java 11 Template",
    action = SetupJava(
        javaVersion = "11",
        distribution = Temurin
    ),
    condition = "false"
)
uses(
    name = "Setup Java 11",
    action = WretryAction(
        step = setupJava11.id
    )
)

which then results in

- id: 'step-5'
  name: 'Setup Java 11 Template'
  uses: 'actions/setup-java@v4'
  with:
    java-version: '11'
    distribution: 'temurin'
  if: 'false'
- id: 'step-6'
  name: 'Setup Java 11'
  uses: 'Wandalen/wretry.action@v3'
  with:
    step: 'step-5'

and then your action figures out the action and with values from the other step. :-)

dmvict commented 1 month ago

Hello @Vampire

The feature you've asked here is impossible because GithubActions is based on system of contexts and isolated steps.

Each step is isolated to the other steps and the only thing that you may use is context output. You may get the context from the previous steps and put it as input of the current one.

Vampire commented 1 month ago

I wouldn't say it is impossible. You can for example either require for that, that the project is checked out so that you know where to find the file or maybe even better allow to configure the file to use. Then you can use js-yaml that you also use to parse the configured with string to parse the workflow file and then find the step with the given id.