Skip to content

Commit 6cb49a1

Browse files
committed
Add matrix and conditionals workflow for GitHub Actions (Testing / Demo)
1 parent bc3def3 commit 6cb49a1

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/matrix.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Matrix and Conditionals
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
matrix-job:
12+
runs-on: ubuntu-24.04
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
number: [1, 2]
17+
letter: [a, b, c]
18+
exclude:
19+
- number: 1
20+
letter: c
21+
timeout-minutes: 5
22+
23+
steps:
24+
# Step 1 – always runs
25+
- name: Echo number and letter
26+
run: |
27+
echo "Number: ${{ matrix.number }}"
28+
echo "Letter: ${{ matrix.letter }}"
29+
30+
# Step 2 – run for every combo EXCEPT number=2 ∧ letter=c
31+
- name: Run everywhere except 2c
32+
if: ${{ ! (matrix.number == 2 && matrix.letter == 'c') }}
33+
run: echo "✔ This step runs for ${{ matrix.number }}${{ matrix.letter }}"
34+
35+
sleep-job:
36+
runs-on: ubuntu-24.04
37+
steps:
38+
- name: Sleep (to give time to be cancelled)
39+
run: sleep 100
40+
timeout-minutes: 2

0 commit comments

Comments
 (0)