forked from mattes/gce-cloudsql-proxy-action
-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
54 lines (47 loc) · 1.53 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
name: 'Google Cloud SQL Proxy with workload identity'
description: 'Start Google CloudSQL Proxy using Google Workload Identity Federation short-lived credentials'
branding:
icon: 'database'
color: 'red'
inputs:
creds:
description: 'Contents of a short-lived GOOGLE_APPLICATION_CREDENTIALS environment variable'
required: false
instance:
description: 'CloudSQL instance'
required: true
port:
description: 'Listen on port'
required: false
default: 5432
proxy_version:
description: 'CloudSQL Proxy Version'
required: false
default: v2.5.0
runs:
using: 'composite'
steps:
- name: Start Google Cloud SQL Proxy
shell: bash
run: |
# Download Linux binary
wget -q https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.5.0/cloud-sql-proxy.linux.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy
# Start Cloud SQL Proxy
./cloud_sql_proxy ${{ inputs.instance }} --address 0.0.0.0 --port ${{ inputs.port }} --health-check --quitquitquit &
# Wait until proxy is ready
isready=1
for i in {1..10}; do
echo "Wait for connections to be ready ... $i/10"
if curl -s -X GET http://localhost:9090/readiness >/dev/null; then
isready=0
break
fi
sleep 2
done
# Exit with error code if we couldn't connect
exit $isready
# exit with error code if we couldn't connect
if [[ $isready -ne 0 ]]; then
exit $isready
fi