-
Notifications
You must be signed in to change notification settings - Fork 7
85 lines (73 loc) · 3.09 KB
/
update_connection.yml
File metadata and controls
85 lines (73 loc) · 3.09 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
name: update_connection
on:
workflow_dispatch:
inputs:
env_url:
description: "Select source and target env's"
type: choice
default: "Source: SANDBOX, Target: PRODUCTION"
options:
- "Source: SANDBOX, Target: PRODUCTION"
- "Source: SANDBOX, Target: SANDBOX"
- "Source: PRODUCTION, Target: PRODUCTION"
- "Source: PRODUCTION, Target: SANDBOX"
source_connection_id:
description: "Source Connection ID"
required: true
target_connection_id:
description: "Target Connection ID"
required: true
source_account_access_token:
description: "Access token of the Source Account"
required: true
target_account_access_token:
description: "Access token of the Target Account"
required: true
source_account_id:
description: "Source Account ID. If not provided, will use the repository variable"
required: false
target_account_id:
description: "Target Account ID. If not provided, will use the repository variable"
required: false
jobs:
execute-update-connection-script:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: pip install requests
- name: Parse and map environment URLs
id: map_envs
shell: bash
run: |
input="${{ github.event.inputs.env_url }}"
source_name=$(echo "$input" | sed -n 's/Source: \([^,]*\),.*/\1/p' | xargs)
target_name=$(echo "$input" | sed -n 's/.*Target: \(.*\)/\1/p' | xargs)
get_env_url() {
case "$1" in
SANDBOX) echo "https://manage.skyflowapis-preview.com" ;;
PRODUCTION) echo "https://manage.skyflowapis.com" ;;
*) echo "Invalid environment: $1" >&2; exit 1 ;;
esac
}
# Resolve URLs
source_url=$(get_env_url "$source_name")
target_url=$(get_env_url "$target_name")
echo "source_url=$source_url" >> $GITHUB_OUTPUT
echo "target_url=$target_url" >> $GITHUB_OUTPUT
- name: Run Python script
env:
SOURCE_CONNECTION_ID: ${{ github.event.inputs.source_connection_id }}
TARGET_CONNECTION_ID: ${{ github.event.inputs.target_connection_id }}
SOURCE_ACCOUNT_AUTH: ${{ github.event.inputs.source_account_access_token }}
TARGET_ACCOUNT_AUTH: ${{ github.event.inputs.target_account_access_token }}
SOURCE_ACCOUNT_ID: ${{ github.event.inputs.source_account_id != '' && github.event.inputs.source_account_id || vars.SOURCE_ACCOUNT_ID }}
TARGET_ACCOUNT_ID: ${{ github.event.inputs.target_account_id != '' && github.event.inputs.target_account_id || vars.TARGET_ACCOUNT_ID }}
SOURCE_ENV_URL: ${{ steps.map_envs.outputs.source_url }}
TARGET_ENV_URL: ${{ steps.map_envs.outputs.target_url }}
run: python3 update_connection.py