-
Notifications
You must be signed in to change notification settings - Fork 13
86 lines (75 loc) · 2.62 KB
/
sync.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
name: Sync Workflow
on:
workflow_call:
inputs:
network:
required: true
type: string
api_url:
required: true
type: string
jobs:
import-validators:
name: Import validators ${{ inputs.network }}
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Import validators
run: |
echo "Importing validators for ${{ inputs.network }}..."
RESPONSE=$(curl -s -X POST "${{ inputs.api_url }}/api/v1/validators/import")
if [ $? -eq 0 ]; then
echo "Successfully imported validators for ${{ inputs.network }}"
else
echo "Error importing validators for ${{ inputs.network }}"
exit 1
fi
sync-epoch-activity:
name: Syncs the epoch activity
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Fetch missing epochs
id: fetch-missing
run: |
MISSING_EPOCHS=$(curl -s "${{ inputs.api_url }}/api/v1/epochs/missing")
EPOCHS=$(echo $MISSING_EPOCHS | jq -r 'join(" ")')
echo "epochs=$EPOCHS" >> $GITHUB_OUTPUT
echo "Found missing epochs for ${{ inputs.network }}: $EPOCHS"
- name: Process each epoch
run: |
EPOCHS="${{ steps.fetch-missing.outputs.epochs }}"
for epoch in $EPOCHS; do
echo "Processing epoch $epoch for ${{ inputs.network }}"
HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" "${{ inputs.api_url }}/api/v1/epochs/$epoch")
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$HTTP_RESPONSE" | sed '$ d')
if [ "$HTTP_STATUS" -eq 500 ]; then
echo "Error 500 received for epoch $epoch"
echo "Response body: $RESPONSE_BODY"
continue
elif [ "$HTTP_STATUS" -ne 200 ]; then
echo "Error: HTTP status $HTTP_STATUS for epoch $epoch"
echo "Response body: $RESPONSE_BODY"
continue
else
echo "Successfully processed epoch $epoch"
fi
done
sync-validator-balances:
name: Syncs the validator balances
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Sync validator balances
run: |
echo "Sync validators balances for ${{ inputs.network }}..."
RESPONSE=$(curl -s -X POST "${{ inputs.api_url }}/api/v1/validators/balances")
ISSUES=$(echo $RESPONSE | jq -r '.issues')
if [ "$ISSUES" != "[]" ]; then
echo "Issues found: $ISSUES"
fi
echo $RESPONSE