-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (68 loc) · 3.1 KB
/
middle-flow.yml
File metadata and controls
76 lines (68 loc) · 3.1 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
name: Middle Flow
run-name: ${{ inputs.workflow_name }}
on:
workflow_call:
inputs:
correlation_id:
description: Correlation id
type: string
required: true
workflow_name:
description: Workflow path
type: string
required: true
api_inputs:
description: Workflow inputs (json)
type: string
required: true
config:
description: Workflow config
type: string
required: true
secrets:
secrets:
description: Secrets info (json)
required: true
github_pat:
description: GitHub Organization PAT
required: true
jobs:
run:
name: Run workflow ${{ inputs.workflow_name }}
runs-on: ${{ fromJson(inputs.config).runner }}
env:
LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
PYTHONIOENCODING: utf-8
HTTP_ENABLE_FILE_DEBUG: false
steps:
- name: Running ${{ inputs.workflow_name }}
env:
GITHUB_PAT: ${{ secrets.github_pat }}
run: |
secret_stk_login=$(echo '${{ secrets.secrets }}' | jq -cr '.cli_token')
execution_id=$(echo '${{ inputs.api_inputs }}' | jq -cr '.execution_id')
http_code=$(curl -s -o script.sh -w '%{http_code}' https://workflow-api.v1.stackspot.com/workflows/$execution_id --header "Authorization: Bearer $secret_stk_login";)
if [[ "$http_code" -ne "200" ]]; then
echo "------------------------------------------------------------------------------------------"
echo "---------------------------------------- Debug Starting ----------------------------------"
echo "------------------------------------------------------------------------------------------"
echo "HTTP_CODE:" $http_code
echo "RESPONSE_CONTENT:"
cat script.sh
exit $http_code
echo "------------------------------------------------------------------------------------------"
echo "---------------------------------------- Debug Ending ------------------------------------"
echo "------------------------------------------------------------------------------------------"
else
chmod +x script.sh
sed -i '/^cmd=./a cmd=$(echo "$cmd" | sed -E "s/\\"idp_token\\": \\"[^\\"]*\\"/\\"idp_token\\": \\"$GITHUB_PAT\\"/g")' script.sh
echo "------------------------------------------------------------------------------------------"
echo "---------------------------------------- Starting ----------------------------------------"
echo "------------------------------------------------------------------------------------------"
bash script.sh
echo "------------------------------------------------------------------------------------------"
echo "---------------------------------------- Ending ----------------------------------------"
echo "------------------------------------------------------------------------------------------"
fi