sab
sab

Reputation: 5022

for, foreach and other loops in github-actions

There is a "if" available in github-actions.

Is there any way to do use loops? (for, foreach, while , ...)

something like

- foreach val in ['val1', 'val2']

Upvotes: 24

Views: 21046

Answers (3)

fabasoad
fabasoad

Reputation: 1873

In one word - no. But there is a matrix mechanism that probably will help you. Share more details about the problem you want to solve using loops.

Upvotes: 12

sorin
sorin

Reputation: 170528

Looping is not currently possible, especially if you consider looping by using the same runner.

Matrix can be used to run a variable number of jobs, but that adds a considerable complexity and huge increase in resource usage, so directly slower results.

Upvotes: 1

user20132365
user20132365

Reputation: 131

Maybe not what you are looking for, but you can use a run in the action

  - name: Print things
    run: |
      for x in ${{ y }}; do
        echo "$x"
      done

Upvotes: 13

Related Questions