https://github.com/cliffano/command-loop-action
GitHub Action for running a shell command in a loop against a list of items
https://github.com/cliffano/command-loop-action
github-action shell-command
Last synced: 9 months ago
JSON representation
GitHub Action for running a shell command in a loop against a list of items
- Host: GitHub
- URL: https://github.com/cliffano/command-loop-action
- Owner: cliffano
- License: mit
- Created: 2024-05-02T18:22:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-19T10:05:27.000Z (12 months ago)
- Last Synced: 2025-02-12T12:17:54.492Z (11 months ago)
- Topics: github-action, shell-command
- Language: Makefile
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/cliffano/command-loop-action/actions?query=workflow%3ACI)
[](https://snyk.io/test/github/cliffano/command-loop-action)
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 | `, \| \|,` | `:` |