-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
73 lines (60 loc) · 2.08 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
---
name: "Autify for Web Run Test Plan"
description: "Runs a Test Plan to execute automated E2E tests on Autify for Web"
author: "Autify"
branding:
icon: "check-circle"
color: "purple"
inputs:
autify_for_web_api_token:
description: "Personal Access Token"
required: true
test_plan_id:
description: "Test Plan ID that you want to run"
required: true
test_plan_api_base_url:
description: "Test Plan API base URL"
default: https://app.autify.com/api/v1/schedules/
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_web_api_token }}"
# Validate parameters
if [ -z "${{ inputs.autify_for_web_api_token }}" ]; then
error "Token should exist"
exit 1
fi
if ! echo "${{ inputs.test_plan_id }}" | grep -Eq '^[0-9]+$'; then
error "Test Plan ID should be string of digits"
exit 1
fi
# Call API
response=$(curl -s -X POST \
-H "Authorization: Bearer ${{ inputs.autify_for_web_api_token }}" \
-H "Content-Type: application/json" \
"${{ inputs.test_plan_api_base_url }}${{ inputs.test_plan_id }}")
# Validate response
if [[ "$( echo ${response} | jq -R 'fromjson? | has("data")' )" == false ]]; then
error "Something went wrong. The response was : ${response}"
exit 1
fi
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}'"