Skip to content

Commit d0d334b

Browse files
committed
Add reusable workflow for running commands in a matrix of environments
- Introduced a reusable GitHub Actions workflow, `RunCommandOnMatrix.yml`, to execute commands across various environments defined by operating systems and PHP versions. - Supports flexible configuration through `inputs` for OS, PHP versions, extensions, tools, and commands, ensuring adaptability to diverse use cases. - Utilizes dynamic job matrix creation based on inputs for operating systems and PHP versions. - Includes steps for repository checkout, PHP setup with customizable extensions and tools, composer dependency installation, and command execution. - Promotes modular and streamlined CI processes across multiple configurations.
1 parent 562f2f1 commit d0d334b

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Run Command on Matrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
title:
7+
type: string
8+
required: true
9+
operatingSystems:
10+
type: string
11+
required: false
12+
default: '["ubuntu-latest", "windows-latest", "macOS-latest"]'
13+
phpVersions:
14+
type: string
15+
required: true
16+
phpExtensions:
17+
type: string
18+
required: true
19+
tools:
20+
type: string
21+
required: true
22+
command:
23+
type: string
24+
required: true
25+
secrets:
26+
GH_TOKEN:
27+
required: true
28+
29+
jobs:
30+
run:
31+
runs-on: ${{ matrix.operating-system }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
operating-system: ${{ fromJson(inputs.operatingSystems) }}
36+
php-versions: ${{ fromJson(inputs.phpVersions) }}
37+
name: ${{ inputs.title }} with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v6
41+
- name: Install PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: ${{ matrix.php-versions }}
45+
extensions: ${{ inputs.phpExtensions }}
46+
tools: ${{ inputs.tools }}
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
49+
- name: Install composer dependencies
50+
run: composer install --no-interaction --no-progress --prefer-dist
51+
- name: ${{ inputs.title }}
52+
run: ${{ inputs.command }}

0 commit comments

Comments
 (0)