Skip to content

Instantly share code, notes, and snippets.

@maniankara
Created July 28, 2023 11:24
Show Gist options
  • Save maniankara/db341998b13b22e182e18d3a22bd7c8a to your computer and use it in GitHub Desktop.
Save maniankara/db341998b13b22e182e18d3a22bd7c8a to your computer and use it in GitHub Desktop.
Github action looping example. This is the only way to natively loop a step in GHA
name: listfiles
on:
workflow_dispatch:
jobs:
list-png-files:
runs-on: ubuntu-latest
outputs:
file: ${{ steps.set-files.outputs.file }}
steps:
- uses: actions/checkout@v2
- id: set-files
run: echo "::set-output name=file::$(ls *.png | jq -R -s -c 'split("\n")[:-1]')"
check:
needs: list-png-files
runs-on: ubuntu-latest
strategy:
matrix:
file: ${{ fromJson(needs.list-png-files.outputs.file) }}
steps:
- run: |
echo "${{ matrix.file }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment