-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (72 loc) · 2.7 KB
/
validate_env.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: Validate Environment JSONs
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
first_json_url:
description: "URL of the reference JSON file (dydxprotocol)"
required: false
default: "https://raw.githubusercontent.com/dydxprotocol/v4-web/main/public/configs/v1/env.json"
second_json_url:
description: "URL of the JSON file to validate (dydxopsdao)"
required: false
default: "https://raw.githubusercontent.com/dydxopsdao/v4-web/faa3fe60bdf0156027849012b41e439146c39c14/public/configs/v1/env.json"
jobs:
validate-json:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
LC_ALL: C.UTF-8
LANG: C.UTF-8
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Set Default URLs
id: set-default-urls
run: |
FIRST_URL="${{ github.event.inputs.first_json_url }}"
SECOND_URL="${{ github.event.inputs.second_json_url }}"
if [ -z "$FIRST_URL" ]; then
FIRST_URL="https://raw.githubusercontent.com/dydxprotocol/v4-web/main/public/configs/v1/env.json"
fi
if [ -z "$SECOND_URL" ]; then
SECOND_URL="https://raw.githubusercontent.com/dydxopsdao/v4-web/faa3fe60bdf0156027849012b41e439146c39c14/public/configs/v1/env.json"
fi
echo "FIRST_URL=$FIRST_URL" >> $GITHUB_ENV
echo "SECOND_URL=$SECOND_URL" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.6'
- name: Check Python Version
run: python --version
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: pip install rich requests beautifulsoup4
- name: Download Reference JSON
run: |
curl -H "Accept: application/json" -L "$FIRST_URL" -o dydx_env.json || exit 1
- name: Download Validation JSON
env:
AUTH_TOKEN: ${{ secrets.DYDXOPSDDAO_REPO_TOKEN }}
run: |
curl -H "Accept: application/json" -H "Authorization: token $AUTH_TOKEN" -L "$SECOND_URL" -o dos_env.json || exit 1
- name: Check File Sizes
run: |
ls -lh dydx_env.json dos_env.json
if [ ! -s dydx_env.json ] || [ ! -s dos_env.json ]; then
echo "Error: One or both JSON files are empty"
exit 1
fi
- name: Validate JSON Files
run: |
cd src
python env_config_validator.py ../dydx_env.json ../dos_env.json