-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
78 lines (64 loc) · 2.26 KB
/
action.yml
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
---
name: "Autify for Mobile Run Test Plan"
description: "Runs a Test Plan to execute automated E2E tests on Autify for Mobile"
author: "Autify"
branding:
icon: "check-circle"
color: "purple"
inputs:
autify_for_mobile_api_token:
description: "Personal Access Token"
required: true
test_plan_id:
description: "Test Plan ID that you want to run"
required: true
build_id:
description: "Build ID that you want to use"
required: true
test_plan_api_base_url:
description: "Test Plan API base URL"
default: https://mobile-app.autify.com/api/v1/test_plans/
required: false
outputs:
response:
value: ${{ steps.run-test-plan-action.outputs.response }}
runs:
using: "composite"
steps:
- name: "Run a Test Plan on Autify for Web"
shell: bash
id: run-test-plan-action
run: |
error () {
echo "::error ::${1}"
}
# Mask the value if it is passed in a way other than GitHub secrets
echo "::add-mask::${{ inputs.autify_for_mobile_api_token }}"
# Validate parameters
if [ -z "${{ inputs.autify_for_mobile_api_token }}" ]; then
error "Token should exist"
exit 1
fi
if ! echo "${{ inputs.test_plan_id }}" | grep -Eq '^[a-zA-Z0-9]+$'; then
error "Test Plan ID should be string of alphabet or digits"
exit 1
fi
if ! echo "${{ inputs.build_id }}" | grep -Eq '^[a-zA-Z0-9]+$'; then
error "Build ID should be string of alphabet or digits"
exit 1
fi
# Call API
response=$(curl -s -X POST \
-H "Authorization: Bearer ${{ inputs.autify_for_mobile_api_token }}" \
-H "Content-Type: application/json" \
-d "{\"build_id\":\"${{ inputs.build_id }}\"}" \
"${{ inputs.test_plan_api_base_url }}${{ inputs.test_plan_id }}/test_plan_results")
# Validate response
if [ "$( echo ${response} | jq -R 'fromjson? | has("errors")' )" == true ]; then
error "Error running the test plan. The error messages are : ${response}"
exit 1
fi
# Outputs
echo "Successfully started the Test Plan."
echo ${response} | jq -R 'fromjson?'
echo "::set-output name=response::'${response}'"