Skip to content

Commit dcb69a6

Browse files
joshwhittickkirillt
authored andcommitted
New workflow for exchange rates updates
1 parent b06a829 commit dcb69a6

File tree

5 files changed

+1141
-186
lines changed

5 files changed

+1141
-186
lines changed

.github/workflows/fetch.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,63 @@
1-
name: Fetch exchange rates
1+
name: Fetch exchange rates v2
22

33
on:
4-
push:
5-
branches: [ "main" ] # On every push to `main`
64
workflow_dispatch:
75
schedule:
8-
- cron: "0 0 * * 1" # Also, regularly at 00:00 on Monday
6+
- cron: "0 0,8,16 * * *"
7+
push:
8+
branches:
9+
- main
10+
- exchange-rates
911

1012
env:
1113
APP_ID: ${{ secrets.APP_ID }}
1214

1315
jobs:
1416
build:
1517
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: write
1621

1722
steps:
18-
- uses: actions/checkout@v3
23+
- name: Check out the repository
24+
uses: actions/checkout@v4
25+
with:
26+
ref: exchange-rates
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: '3.x'
1932

33+
- name: Install dependencies
34+
run: |
35+
pip install --upgrade pip
36+
pip install requests
37+
38+
- name: Run fetch-rates.py script
39+
run: python fetch-rates.py
40+
2041
- name: Fetch fiat
21-
run: curl -X GET "https://openexchangerates.org/api/latest.json?app_id=${{ secrets.APP_ID }}" --output core/data/src/main/assets/fiat-rates.json
42+
run: curl -X GET "https://openexchangerates.org/api/latest.json?app_id=${{secrets.APP_ID}}" --output core/data/src/main/assets/fiat-rates.json
2243

23-
- name: Fetch crypto
24-
run: curl -X GET "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd" --output core/data/src/main/assets/crypto-rates.json
44+
- name: Check if APP_ID secret is set
45+
run: |
46+
if [ -z "${{ secrets.APP_ID }}" ]; then
47+
echo "APP_ID is NOT set"
48+
else
49+
echo "APP_ID is set (value is masked)"
50+
fi
2551
52+
- name: Move JSON file to assets directory
53+
run: mv crypto-rates.json core/data/src/main/assets/
54+
2655
- name: Push into Git
2756
run: |-
2857
git config --global user.email "[email protected]"
2958
git config --global user.name "ARK Builders Bot"
3059
git add core/data/src/main/assets/fiat-rates.json
3160
git add core/data/src/main/assets/crypto-rates.json
32-
git commit -m "Automated update of rates"
33-
git push
61+
git commit -m "Automatic update of rates" || echo "Nothing to commit"
62+
git pull origin exchange-rates --no-edit
63+
git push origin exchange-rates

core/data/src/main/assets/crypto-rates.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 4 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,6 @@
11
{
2-
"disclaimer": "Usage subject to terms: https://openexchangerates.org/terms",
3-
"license": "https://openexchangerates.org/license",
4-
"timestamp": 1742976045,
5-
"base": "USD",
6-
"rates": {
7-
"AED": 3.673015,
8-
"AFN": 70.790967,
9-
"ALL": 91.5336,
10-
"AMD": 392.167883,
11-
"ANG": 1.806323,
12-
"AOA": 913.666667,
13-
"ARS": 1070.6796,
14-
"AUD": 1.582119,
15-
"AWG": 1.8025,
16-
"AZN": 1.7,
17-
"BAM": 1.811958,
18-
"BBD": 2,
19-
"BDT": 121.782298,
20-
"BGN": 1.812428,
21-
"BHD": 0.376983,
22-
"BIF": 2970.685648,
23-
"BMD": 1,
24-
"BND": 1.339386,
25-
"BOB": 6.92524,
26-
"BRL": 5.701299,
27-
"BSD": 1,
28-
"BTC": 0.00001133944,
29-
"BTN": 85.9091,
30-
"BWP": 13.664389,
31-
"BYN": 3.279893,
32-
"BZD": 2.013165,
33-
"CAD": 1.425029,
34-
"CDF": 2872.965535,
35-
"CHF": 0.883595,
36-
"CLF": 0.023972,
37-
"CLP": 919.78,
38-
"CNH": 7.2724,
39-
"CNY": 7.2632,
40-
"COP": 4152.90904,
41-
"CRC": 499.73365,
42-
"CUC": 1,
43-
"CUP": 25.75,
44-
"CVE": 102.155385,
45-
"CZK": 23.090988,
46-
"DJF": 178.471985,
47-
"DKK": 6.916084,
48-
"DOP": 63.305149,
49-
"DZD": 133.758479,
50-
"EGP": 50.5699,
51-
"ERN": 15,
52-
"ETB": 131.521744,
53-
"EUR": 0.926979,
54-
"FJD": 2.29315,
55-
"FKP": 0.774839,
56-
"GBP": 0.774839,
57-
"GEL": 2.77,
58-
"GGP": 0.774839,
59-
"GHS": 15.534772,
60-
"GIP": 0.774839,
61-
"GMD": 72.499999,
62-
"GNF": 8667.058477,
63-
"GTQ": 7.723843,
64-
"GYD": 210.295704,
65-
"HKD": 7.774968,
66-
"HNL": 25.637986,
67-
"HRK": 6.986143,
68-
"HTG": 131.343299,
69-
"HUF": 370.4735,
70-
"IDR": 16588.438558,
71-
"ILS": 3.66584,
72-
"IMP": 0.774839,
73-
"INR": 85.735945,
74-
"IQD": 1312.97294,
75-
"IRR": 42112.5,
76-
"ISK": 133.53,
77-
"JEP": 0.774839,
78-
"JMD": 157.266946,
79-
"JOD": 0.709,
80-
"JPY": 150.435,
81-
"KES": 129.4,
82-
"KGS": 86.4665,
83-
"KHR": 4013.305874,
84-
"KMF": 455.649907,
85-
"KPW": 900,
86-
"KRW": 1464.405224,
87-
"KWD": 0.308352,
88-
"KYD": 0.835198,
89-
"KZT": 504.212903,
90-
"LAK": 21710.636201,
91-
"LBP": 89560.314635,
92-
"LKR": 297.15711,
93-
"LRD": 200.449335,
94-
"LSL": 18.199639,
95-
"LYD": 4.845352,
96-
"MAD": 9.596761,
97-
"MDL": 18.050626,
98-
"MGA": 4676.761099,
99-
"MKD": 56.997943,
100-
"MMK": 2098,
101-
"MNT": 3398,
102-
"MOP": 8.026886,
103-
"MRU": 39.899016,
104-
"MUR": 45.709998,
105-
"MVR": 15.4,
106-
"MWK": 1737.855683,
107-
"MXN": 20.0625,
108-
"MYR": 4.4296,
109-
"MZN": 63.899993,
110-
"NAD": 18.199809,
111-
"NGN": 1535.5,
112-
"NIO": 36.882455,
113-
"NOK": 10.506289,
114-
"NPR": 137.455459,
115-
"NZD": 1.738067,
116-
"OMR": 0.38498,
117-
"PAB": 1,
118-
"PEN": 3.656527,
119-
"PGK": 4.128315,
120-
"PHP": 57.702999,
121-
"PKR": 281.002265,
122-
"PLN": 3.861256,
123-
"PYG": 8005.569563,
124-
"QAR": 3.653377,
125-
"RON": 4.6131,
126-
"RSD": 108.623,
127-
"RUB": 84.423823,
128-
"RWF": 1442.594149,
129-
"SAR": 3.751484,
130-
"SBD": 8.421986,
131-
"SCR": 14.353761,
132-
"SDG": 600.5,
133-
"SEK": 10.051855,
134-
"SGD": 1.337057,
135-
"SHP": 0.774839,
136-
"SLL": 20969.5,
137-
"SOS": 572.739118,
138-
"SRD": 36.35,
139-
"SSP": 130.26,
140-
"STD": 22281.8,
141-
"STN": 22.698321,
142-
"SVC": 8.769809,
143-
"SYP": 13002,
144-
"SZL": 18.204811,
145-
"THB": 33.9529,
146-
"TJS": 10.934375,
147-
"TMT": 3.5,
148-
"TND": 3.108066,
149-
"TOP": 2.40776,
150-
"TRY": 38.007755,
151-
"TTD": 6.816782,
152-
"TWD": 33.084001,
153-
"TZS": 2662.5,
154-
"UAH": 41.777881,
155-
"UGX": 3675.247578,
156-
"USD": 1,
157-
"UYU": 42.137948,
158-
"UZS": 12958.393514,
159-
"VES": 68.308144,
160-
"VND": 25619,
161-
"VUV": 118.722,
162-
"WST": 2.8,
163-
"XAF": 608.058676,
164-
"XAG": 0.02960367,
165-
"XAU": 0.00033044,
166-
"XCD": 2.70255,
167-
"XDR": 0.755808,
168-
"XOF": 608.058676,
169-
"XPD": 0.00105491,
170-
"XPF": 110.618076,
171-
"XPT": 0.00103441,
172-
"YER": 246.049963,
173-
"ZAR": 18.21161,
174-
"ZMW": 29.0144,
175-
"ZWL": 322
176-
}
2+
"error": true,
3+
"status": 403,
4+
"message": "missing_app_id",
5+
"description": "No App ID provided. Please sign up at https://openexchangerates.org/signup, or contact [email protected]."
1776
}

0 commit comments

Comments
 (0)