-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
137 lines (119 loc) · 4.13 KB
/
Copy pathaction.yml
File metadata and controls
137 lines (119 loc) · 4.13 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: 'Find Phone - Enrow'
description: 'Find a mobile phone number from LinkedIn or name + company'
branding:
icon: 'phone'
color: 'purple'
inputs:
api_key:
description: 'Your Enrow API key'
required: true
linkedin_url:
description: 'LinkedIn profile URL (preferred)'
required: false
first_name:
description: 'First name of the person'
required: false
last_name:
description: 'Last name of the person'
required: false
company_domain:
description: 'Company domain (e.g. "apple.com")'
required: false
wait:
description: 'Poll until the result is ready (true/false)'
required: false
default: 'true'
outputs:
number:
description: 'The found phone number'
value: ${{ steps.result.outputs.number }}
country:
description: 'Country code of the phone number'
value: ${{ steps.result.outputs.country }}
qualification:
description: 'Result qualification (found, not_found, ongoing)'
value: ${{ steps.result.outputs.qualification }}
id:
description: 'The search ID'
value: ${{ steps.result.outputs.id }}
raw:
description: 'Full JSON response'
value: ${{ steps.result.outputs.raw }}
runs:
using: 'composite'
steps:
- name: Find phone
id: result
shell: bash
env:
API_KEY: ${{ inputs.api_key }}
LINKEDIN_URL: ${{ inputs.linkedin_url }}
FIRST_NAME: ${{ inputs.first_name }}
LAST_NAME: ${{ inputs.last_name }}
COMPANY_DOMAIN: ${{ inputs.company_domain }}
WAIT: ${{ inputs.wait }}
run: |
set -euo pipefail
# Build JSON payload
PAYLOAD=$(jq -n \
--arg li "$LINKEDIN_URL" \
--arg fn "$FIRST_NAME" \
--arg ln "$LAST_NAME" \
--arg cd "$COMPANY_DOMAIN" \
'{}
+ (if $li != "" then {linkedin_url: $li} else {} end)
+ (if $fn != "" then {first_name: $fn} else {} end)
+ (if $ln != "" then {last_name: $ln} else {} end)
+ (if $cd != "" then {company_domain: $cd} else {} end)')
echo "::debug::Calling POST /phone/single"
RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST "https://api.enrow.io/phone/single" \
-H "Content-Type: application/json" \
-H "x-api-key: $API_KEY" \
-d "$PAYLOAD")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ge 400 ]; then
echo "::error::API returned HTTP $HTTP_CODE: $BODY"
exit 1
fi
ID=$(echo "$BODY" | jq -r '.id // empty')
STATUS=$(echo "$BODY" | jq -r '.status // empty')
# Poll if wait=true and status is pending/ongoing
if [ "$WAIT" = "true" ] && [ -n "$ID" ]; then
echo "::debug::Polling for result (id=$ID)"
ELAPSED=0
while [ "$ELAPSED" -lt 30 ]; do
sleep 3
ELAPSED=$((ELAPSED + 3))
POLL=$(curl -s -w "\n%{http_code}" \
-X GET "https://api.enrow.io/phone/single?id=$ID" \
-H "x-api-key: $API_KEY")
POLL_CODE=$(echo "$POLL" | tail -1)
BODY=$(echo "$POLL" | sed '$d')
if [ "$POLL_CODE" -ge 400 ]; then
echo "::error::Poll returned HTTP $POLL_CODE: $BODY"
exit 1
fi
QUALIFICATION=$(echo "$BODY" | jq -r '.qualification // empty')
if [ "$QUALIFICATION" != "ongoing" ] && [ -n "$QUALIFICATION" ]; then
break
fi
done
QUALIFICATION=$(echo "$BODY" | jq -r '.qualification // empty')
if [ "$QUALIFICATION" = "ongoing" ]; then
echo "::warning::Search still ongoing after 30 seconds (id=$ID)"
fi
fi
# Set outputs
{
echo "id=$ID"
echo "number=$(echo "$BODY" | jq -r '.phone // empty')"
echo "country=$(echo "$BODY" | jq -r '.country_code // empty')"
echo "qualification=$(echo "$BODY" | jq -r '.qualification // empty')"
} >> "$GITHUB_OUTPUT"
{
echo "raw<<ENROW_EOF"
echo "$BODY"
echo "ENROW_EOF"
} >> "$GITHUB_OUTPUT"