-
Notifications
You must be signed in to change notification settings - Fork 9
/
entrypoint.sh
127 lines (107 loc) · 2.97 KB
/
entrypoint.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
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
#! /usr/bin/env bash
set -e
export PYTHONUNBUFFERED=1
if [ -z "$CONTROLLER_HOST" ]; then
echo "Controller host is not set. Exiting."
exit 1
fi
if [ -z "$CONTROLLER_OAUTH_TOKEN" ]; then
echo "Controller oauth token is not set. Exiting."
exit 1
fi
if [ -z "$CONTROLLER_VERIFY_SSL" ]; then
CONTROLLER_VERIFY_SSL="true"
elif [ $CONTROLLER_VERIFY_SSL = "true" ]; then
CONTROLLER_VERIFY_SSL="true"
elif [ $CONTROLLER_VERIFY_SSL = "false" ]; then
CONTROLLER_VERIFY_SSL="false"
else
echo "Unknown ssl verify value. Exiting."
exit 1
fi
if [ -z "$RESOURCE_TYPE" ]; then
echo "Resource type is not set. Exiting."
exit 1
fi
if [ -z "$RESOURCE_NAME" ]; then
echo "Resource name or id is not set. Exiting."
exit 1
else
RESOURCE_NAME="'$RESOURCE_NAME'"
fi
if [ -z "$LIMIT" ]; then
LIMIT_VALUE=""
else
LIMIT_VALUE="--limit '$LIMIT'"
fi
if [ -z "$TAGS" ]; then
TAGS_VALUE=""
else
TAGS_VALUE="--job_tags '$TAGS'"
fi
if [ -z "$SKIP_TAGS" ]; then
SKIP_TAGS_VALUE=""
else
SKIP_TAGS_VALUE="--skip_tags '$SKIP_TAGS'"
fi
if [ -z "$TIMEOUT" ]; then
TIMEOUT_VALUE="--action-timeout 3600"
else
TIMEOUT_VALUE="--action-timeout $TIMEOUT"
fi
if [ -z "$INVENTORY" ]; then
INVENTORY_VALUE=""
else
INVENTORY_VALUE="--inventory '$INVENTORY'"
fi
if [ -z "$CREDENTIALS" ]; then
CREDENTIALS_VALUE=""
else
CREDENTIALS_VALUE="--credentials '$CREDENTIALS'"
fi
if [ -z "$BRANCH" ]; then
BRANCH_VALUE=""
else
BRANCH_VALUE="--scm_branch '$BRANCH'"
fi
if [ -z "$MONITOR" ]; then
MONITOR="true"
fi
if [ $MONITOR = "true" ]; then
MONITOR_VALUE="--monitor"
elif [ $MONITOR = "false" ]; then
MONITOR_VALUE=""
else
echo "Unknown monitor value. Exiting."
exit 1
fi
if [ -z "$EXTRA_VARS" ]; then
EXTRA_VARS_VALUE=""
else
EXTRA_VARS_VALUE="--extra_vars '$EXTRA_VARS'"
fi
if [ -z "$JOB_TYPE" ]; then
JOB_TYPE_VALUE=""
elif [ $JOB_TYPE = "run" ]; then
JOB_TYPE_VALUE="--job_type 'run'"
elif [ $JOB_TYPE = "check" ]; then
JOB_TYPE_VALUE="--job_type 'check'"
else
echo "Unknown job type type. Exiting."
exit 1
fi
if [ $RESOURCE_TYPE = "job_template" ]; then
ACTION="job_templates launch"
elif [ $RESOURCE_TYPE = "workflow_job_template" ]; then
ACTION="workflow_job_templates launch"
elif [ $RESOURCE_TYPE = "project" ]; then
ACTION="projects update"
elif [ $RESOURCE_TYPE = "inventory_source" ]; then
ACTION="inventory_sources update"
else
echo "Unknown resource type. Exiting."
exit 1
fi
echo "awx ${ACTION} ${RESOURCE_NAME} -f jq --filter .id ${MONITOR_VALUE} ${TIMEOUT_VALUE} ${LIMIT_VALUE} ${INVENTORY_VALUE} ${CREDENTIALS_VALUE} ${EXTRA_VARS_VALUE} ${BRANCH_VALUE} ${JOB_TYPE_VALUE} ${TAGS_VALUE} ${SKIP_TAGS_VALUE}"
echo "awx ${ACTION} ${RESOURCE_NAME} -f jq --filter .id ${MONITOR_VALUE} ${TIMEOUT_VALUE} ${LIMIT_VALUE} ${INVENTORY_VALUE} ${CREDENTIALS_VALUE} ${EXTRA_VARS_VALUE} ${BRANCH_VALUE} ${JOB_TYPE_VALUE} ${TAGS_VALUE} ${SKIP_TAGS_VALUE}" | bash | tee awxkit-output.log
echo job_id="$(sed -e 's/[[:space:]]*$//' awxkit-output.log | awk 'NF' | tail -n 1)" >> $GITHUB_OUTPUT