-
Notifications
You must be signed in to change notification settings - Fork 5
132 lines (120 loc) · 4.88 KB
/
reusable-fetch-network-node-ips.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
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
128
129
130
131
132
name: Fetch Network Node IPs
on:
workflow_call:
inputs:
role_to_assume:
description: "The role to assume"
required: true
type: string
aws_region:
description: "The AWS region to use"
required: true
type: string
devnet_changed:
description: "Boolean to check if DevNet files have changed"
required: true
type: string
testnet_changed:
description: "Boolean to check if TestNet files have changed"
required: true
type: string
network_odyssey_devnet:
description: "The network name for Odyssey DevNet"
required: true
type: string
network_odyssey_testnet:
description: "The network name for Odyssey TestNet"
required: true
type: string
aws_regions:
description: "Comma-separated list of AWS regions"
required: true
type: string
outputs:
node_ips_odyssey_devnet:
description: "The IP addresses for DevNet"
value: ${{ jobs.fetch_network_node_ips.outputs.node_ips_odyssey_devnet }}
node_ips_odyssey_testnet:
description: "The IP addresses for TestNet"
value: ${{ jobs.fetch_network_node_ips.outputs.node_ips_odyssey_testnet }}
jobs:
fetch_network_node_ips:
runs-on: ubuntu-latest
outputs:
node_ips_odyssey_devnet: ${{ steps.get_all_node_ips.outputs.node_ips_odyssey_devnet }}
node_ips_odyssey_testnet: ${{ steps.get_all_node_ips.outputs.node_ips_odyssey_testnet }}
steps:
- name: Checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ inputs.role_to_assume }}
aws-region: ${{ inputs.aws_region }}
role-session-name: github-actions
- name: Fetch All Network Node IPs, Regions, and SSH Users
id: get_all_node_ips
run: |
DEVNET_CHANGED="${{ inputs.devnet_changed }}"
TESTNET_CHANGED="${{ inputs.testnet_changed }}"
NETWORK_ODYSSEY_DEVNET="${{ inputs.network_odyssey_devnet }}"
NETWORK_ODYSSEY_TESTNET="${{ inputs.network_odyssey_testnet }}"
# Convert the comma-separated regions into an array
IFS=',' read -ra regions <<< "${{ inputs.aws_regions }}"
pwd
ls -la
# Make the script executable
chmod +x scripts/fetch_all_node_ips.sh
if [ "$DEVNET_CHANGED" = "true" ]; then
echo "Fetching DevNet Node IPs"
DEVNET_NODE_IPS=""
for region in "${regions[@]}"; do
NODE_INFOS=$(./scripts/fetch_all_node_ips.sh "$NETWORK_ODYSSEY_DEVNET" "$region")
if [ -n "$NODE_INFOS" ]; then
# Append node infos to DEVNET_NODE_IPS, separated by semicolons
while IFS= read -r line; do
DEVNET_NODE_IPS+="${line};"
done <<< "$NODE_INFOS"
fi
done
# Remove trailing semicolon
DEVNET_NODE_IPS="${DEVNET_NODE_IPS%?}"
echo "node_ips_odyssey_devnet<<EOF" >> $GITHUB_OUTPUT
echo "$DEVNET_NODE_IPS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Odyssey DevNet Node IPs: $DEVNET_NODE_IPS"
else
echo "DevNet unchanged, skipping Node IP fetch"
fi
if [ "$TESTNET_CHANGED" = "true" ]; then
echo "Fetching TestNet Node IPs"
TESTNET_NODE_IPS=""
for region in "${regions[@]}"; do
NODE_INFOS=$(./scripts/fetch_all_node_ips.sh "$NETWORK_ODYSSEY_TESTNET" "$region")
if [ -n "$NODE_INFOS" ]; then
# Append node infos to TESTNET_NODE_IPS, separated by semicolons
while IFS= read -r line; do
TESTNET_NODE_IPS+="${line};"
done <<< "$NODE_INFOS"
fi
done
# Remove trailing semicolon
TESTNET_NODE_IPS="${TESTNET_NODE_IPS%?}"
echo "node_ips_odyssey_testnet<<EOF" >> $GITHUB_OUTPUT
echo "$TESTNET_NODE_IPS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Odyssey TestNet Node IPs: $TESTNET_NODE_IPS"
else
echo "TestNet unchanged, skipping Node IP fetch"
fi
# If both are false, output a message
if [ "$DEVNET_CHANGED" = "false" ] && [ "$TESTNET_CHANGED" = "false" ]; then
echo "No changes detected for either network, no Node IPs fetched"
fi
# Display the fetched Node IPs (if any)
if [ -n "$DEVNET_NODE_IPS" ]; then
echo "Odyssey DevNet Node IPs: $DEVNET_NODE_IPS"
fi
if [ -n "$TESTNET_NODE_IPS" ]; then
echo "Odyssey TestNet Node IPs: $TESTNET_NODE_IPS"
fi