Reputation: 893
I have a GitHub Actions workflow dealing with new releases. Some last steps build the application for different platforms. Instead of creating multiple steps where each one builds for a different platform or creating a step running multiple commands I'm looking for a way to loop a step for each item in an array.
I know there is a matrix for jobs so this is my pseudo implementation to show what I'm looking for:
jobs:
do_it:
runs-on: ubuntu-latest
steps:
- name: For each entry in the array...
strategy:
matrix:
target: [ this, that, something ]
run: echo ${{ matrix.target }}
Is it possible to create something similar to a matrix so it will loop the step multiple times?
As a side note, I know there is a similar question but I don't want to split the job into multiple jobs because then I have to deal with all the build artifacts.
Upvotes: 14
Views: 4632
Reputation: 469
If your action uses the workflow_dispatch
event, you can trigger the action again by running a step that runs that same workflow:
- run: gh workflow run run-tests.yml
env:
GH_TOKEN: ${{ github.token }}
Upvotes: 0
Reputation: 6832
Posting this "late" answer hoping that someone finds it useful:
There is no direct or "native" way to loop through a GitHub action step, but you can achieve that with 2 different approaches:
Upvotes: 0