Skip to content

Commit 2c309ba

Browse files
authored
Update test.yaml
1 parent bdc6d19 commit 2c309ba

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

.github/workflows/test.yaml

+32-15
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,63 @@ on:
1717
type: number
1818

1919
jobs:
20-
test-inputs:
20+
test-push-pull-request:
2121
runs-on: ubuntu-latest
22+
if: github.event_name == 'push' || github.event_name == 'pull_request'
2223
steps:
2324
- uses: actions/checkout@v3
24-
- name: Run action (inputs only)
25+
- name: Run action (no inputs expected)
2526
uses: ./
2627
id: print_inputs
27-
- name: Check output (inputs only)
28+
- name: Check output (no inputs expected)
29+
run: |
30+
echo "Action output:"
31+
echo "${{ steps.print_inputs.outputs.output }}"
32+
33+
if [[ "${{ steps.print_inputs.outputs.output }}" == *"No workflow_dispatch inputs found in the event payload."* ]]; then
34+
echo "Test passed: No inputs were found, as expected for push/pull_request events"
35+
else
36+
echo "Test failed: Unexpected output for push/pull_request events"
37+
exit 1
38+
fi
39+
40+
test-workflow-dispatch:
41+
runs-on: ubuntu-latest
42+
if: github.event_name == 'workflow_dispatch'
43+
steps:
44+
- uses: actions/checkout@v3
45+
- name: Run action (inputs expected)
46+
uses: ./
47+
id: print_inputs
48+
- name: Check output (inputs expected)
2849
run: |
2950
echo "Action output:"
3051
echo "${{ steps.print_inputs.outputs.output }}"
3152
3253
if [[ "${{ steps.print_inputs.outputs.output }}" == *"test_name"* && "${{ steps.print_inputs.outputs.output }}" == *"test_number"* ]]; then
33-
echo "Test passed: Inputs were printed correctly"
54+
echo "Test passed: Inputs were printed correctly for workflow_dispatch event"
3455
else
35-
echo "Test failed: Inputs were not printed as expected"
36-
echo "Expected to find 'test_name' and 'test_number' in the output"
56+
echo "Test failed: Inputs were not printed as expected for workflow_dispatch event"
3757
exit 1
3858
fi
3959
40-
test-inputs-and-env:
60+
test-env-vars:
4161
runs-on: ubuntu-latest
4262
steps:
4363
- uses: actions/checkout@v3
44-
- name: Run action (inputs and env vars)
64+
- name: Run action (with env vars)
4565
uses: ./
4666
id: print_inputs_and_env
4767
with:
4868
print_env_vars: 'true'
49-
- name: Check output (inputs and env vars)
69+
- name: Check output (env vars)
5070
run: |
5171
echo "Action output:"
5272
echo "${{ steps.print_inputs_and_env.outputs.output }}"
5373
54-
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"test_name"* &&
55-
"${{ steps.print_inputs_and_env.outputs.output }}" == *"test_number"* &&
56-
"${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* ]]; then
57-
echo "Test passed: Inputs and env vars were printed correctly"
74+
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* && "${{ steps.print_inputs_and_env.outputs.output }}" == *"GITHUB_"* ]]; then
75+
echo "Test passed: Environment variables were printed correctly"
5876
else
59-
echo "Test failed: Inputs or env vars were not printed as expected"
60-
echo "Expected to find 'test_name', 'test_number', and 'Printing environment variables:' in the output"
77+
echo "Test failed: Environment variables were not printed as expected"
6178
exit 1
6279
fi

0 commit comments

Comments
 (0)