-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (72 loc) · 2.61 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Test Action
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
test_name:
description: 'Test name input'
required: true
type: string
test_number:
description: 'Test number input'
required: false
type: number
jobs:
test-push-pull-request:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Run action (no inputs expected)
uses: ./
id: print_inputs
- name: Check output (no inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"No workflow_dispatch inputs found in the event payload."* ]]; then
echo "Test passed: No inputs were found, as expected for push/pull_request events"
else
echo "Test failed: Unexpected output for push/pull_request events"
exit 1
fi
test-workflow-dispatch:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Run action (inputs expected)
uses: ./
id: print_inputs
- name: Check output (inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"test_name"* && "${{ steps.print_inputs.outputs.output }}" == *"test_number"* ]]; then
echo "Test passed: Inputs were printed correctly for workflow_dispatch event"
else
echo "Test failed: Inputs were not printed as expected for workflow_dispatch event"
exit 1
fi
test-env-vars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run action (with env vars)
uses: ./
id: print_inputs_and_env
with:
print_env_vars: 'true'
- name: Check output (env vars)
run: |
echo "Action output:"
echo "${{ steps.print_inputs_and_env.outputs.output }}"
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* && "${{ steps.print_inputs_and_env.outputs.output }}" == *"GITHUB_"* ]]; then
echo "Test passed: Environment variables were printed correctly"
else
echo "Test failed: Environment variables were not printed as expected"
exit 1
fi