Skip to content
repeat

GitHub Action

Command Loop GitHub Action

v1.0.0 Latest version

Command Loop GitHub Action

repeat

Command Loop GitHub Action

A simple GitHub Action for running a shell command in a loop against a list of items

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Command Loop GitHub Action

uses: cliffano/command-loop-action@v1.0.0

Learn more about this action in cliffano/command-loop-action

Choose a version

Avatar

Build Status Security Status

Command Loop GitHub Action

A simple GitHub Action for running a shell command in a loop against a list of items.

The items are comma and/or space-separated strings. Each item can be referenced in the command using $ITEM.

Usage

Looping through a space-separated list of items:

jobs:
  build:
    steps:
      - name: 'Count from 1 to 10 with space-separated items'
        uses: cliffano/command-loop-action@main
        with:
          items: '1 2 3 4 5 6 7 8 9 10'
          command: 'echo "Count $ITEM"'

Looping through a comma-separated list of items:

jobs:
  build:
    steps:
      - name: 'Count from 1 to 10 with comma-separated items'
        uses: cliffano/command-loop-action@main
        with:
          items: '1,2,3,4,5,6,7,8,9,10'
          command: 'echo "Count $ITEM"'

Looping through a comma and space-separated list of items:

jobs:
  build:
    steps:
      - name: 'Count from 1 to 10 with comma and space-separated items'
        uses: cliffano/command-loop-action@main
        with:
          items: '1, 2, 3, 4, 5, 6, 7, 8, 9, 10'
          command: 'echo "Count $ITEM"'

Looping through a list of items from an environment variable:

env:
  NUMBERS: '1, 2, 3, 4, 5, 6, 7, 8, 9, 10'
jobs:
  build:
    steps:
      - name: 'Count from 1 to 10 with items from an environment variable'
        uses: cliffano/command-loop-action@main
        with:
          items: ${{ env.NUMBERS }}
          command: 'echo "Count $ITEM"'

Looping through a list of items with custom delimiters:

jobs:
  build:
    steps:
      - name: 'Count from 1 to 10 with colon-separated items'
        uses: cliffano/command-loop-action@main
        with:
          items: '1:2:3:4:5:6:7:8:9:10'
          command: 'echo "Count $ITEM"'
          delimiters: ':'

Configuration

Input Type Description Required Default Example
items string Comma and/or space-separated list of items, or custom delimiters Yes - 1 2 3 4 5 6 7 8 9 10
command string Shell command to run in a loop, each run can access an item from the list via $ITEM Yes - echo "Count $ITEM"
delimiters string Items string delimiters, separated by pipe character No , | |, :