Skip to content

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

License

Notifications You must be signed in to change notification settings

cliffano/command-loop-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 , | |, :

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •