An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

Avatar

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