Skip to content

Commit 750b218

Browse files
authored
feat: add triggered output to action.yml (#78)
1 parent 3e80caa commit 750b218

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

.github/workflows/tests.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ jobs:
2727
- name: backend
2828
dir: backend
2929
triggers: ('backend/')
30+
expected_triggered: false
3031
- name: frontend-merge
3132
dir: frontend
3233
triggers: ('.')
34+
expected_triggered: true
3335
- name: frontend-pr
3436
dir: frontend
37+
expected_triggered: true
3538
steps:
3639
- uses: actions/checkout@v5
37-
- uses: ./
40+
- id: action
41+
uses: ./
3842
with:
3943
commands: |
4044
npm ci
@@ -51,3 +55,38 @@ jobs:
5155
-Dsonar.tests.inclusions=**/*spec.ts
5256
sonar_token: ${{ matrix.name == 'backend' && secrets.SONAR_TOKEN_BACKEND || secrets.SONAR_TOKEN_FRONTEND }}
5357
triggers: ${{ matrix.triggers }}
58+
59+
- name: Verify trigger behavior
60+
run: |
61+
echo "🔍 Verifying trigger behavior for ${{ matrix.name }}"
62+
echo "Expected: ${{ matrix.expected_triggered }}"
63+
echo "Actual: ${{ steps.action.outputs.triggered }}"
64+
65+
case "${{ matrix.name }}" in
66+
"backend")
67+
if [ "${{ steps.action.outputs.triggered }}" != "false" ]; then
68+
echo "❌ Backend job should NOT have been triggered (no backend/ changes)"
69+
exit 1
70+
else
71+
echo "✅ Backend job correctly NOT triggered"
72+
fi
73+
;;
74+
"frontend-merge")
75+
if [ "${{ steps.action.outputs.triggered }}" != "true" ]; then
76+
echo "❌ Frontend-merge job should have been triggered (triggers: '.')"
77+
exit 1
78+
else
79+
echo "✅ Frontend-merge job correctly triggered"
80+
fi
81+
;;
82+
"frontend-pr")
83+
if [ "${{ steps.action.outputs.triggered }}" != "true" ]; then
84+
echo "❌ Frontend-pr job should have been triggered (no triggers = always run)"
85+
exit 1
86+
else
87+
echo "✅ Frontend-pr job correctly triggered"
88+
fi
89+
;;
90+
esac
91+
92+
echo "🎉 ${{ matrix.name }} trigger behavior verified correctly!"

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ inputs:
4949
description: Non-default branch to clone (used for testing this action)
5050
default: ""
5151

52+
outputs:
53+
triggered:
54+
description: Whether the action was triggered based on path changes
55+
value: ${{ steps.diff.outputs.triggered }}
56+
5257
runs:
5358
using: composite
5459
steps:

0 commit comments

Comments
 (0)