-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.sh
60 lines (50 loc) · 1.38 KB
/
upload.sh
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
#!/bin/bash
set -e
if [ -z "${AVIATOR_API_TOKEN}" ]; then
echo "AVIATOR_API_TOKEN is required."
exit 1
fi
if [ -z "${ASSETS}" ]; then
echo "ASSETS is required."
exit 1
fi
echo "Assets: $ASSETS"
all_files=()
for filename in ${ASSETS}; do
if [ -f "$filename" ]; then
all_files+=(-F "file[]=@$filename")
fi
done
if [ "${#all_files[@]}" -eq 0 ]; then
if [ "${ASSETS_REQUIRED}" = "true" ]; then
echo "No asset files found to upload."
exit 1
else
echo "WARNING: No asset files found to upload."
exit 0
fi
else
echo "Files found: "
echo "${all_files[@]}"
fi
if ! which curl > /dev/null; then
echo "curl is required to use this command"
exit 1
fi
if [[ -z "${AVIATOR_UPLOAD_URL}" ]]; then
URL="https://upload.aviator.co/api/test-report-uploader"
else
URL="${AVIATOR_UPLOAD_URL}"
fi
response=$(curl -X POST -H "x-Aviator-Api-Key: ${AVIATOR_API_TOKEN}" \
-H "Provider-Name: github_action" \
-H "Job-Name: ${GITHUB_JOB}" \
-H "Workflow-Name: ${GITHUB_WORKFLOW}" \
-H "Build-URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
-H "Build-ID: ${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}" \
-H "Commit-Sha: ${GITHUB_SHA}" \
-H "Repo-Url: https://github.com/${GITHUB_REPOSITORY}" \
-H "Branch-Name: ${GITHUB_REF_NAME}" \
"${all_files[@]}" \
"$URL")
echo "$response"