Skip to content

Commit 1de5328

Browse files
committed
Add flutter hash fetcher.
1 parent 9bdb727 commit 1de5328

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Generate Files from Flutter JSON
2+
3+
on:
4+
schedule:
5+
- cron: "0 2 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
generate_files:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: 3.x
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install requests
24+
25+
- name: Generate Files
26+
run: |
27+
python flutter_hash/tools/fetcher.py
28+
29+
- name: Commit & Push changes
30+
uses: actions-js/push@master
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}

flutter_hash/tools/fetcher.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import json
2+
import os
3+
4+
import requests
5+
6+
url = 'https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json'
7+
response = requests.get(url)
8+
9+
if response.status_code == 200:
10+
data = json.loads(response.text)
11+
hash_list = data['releases']
12+
13+
folder_path = '../hash'
14+
os.makedirs(folder_path, exist_ok=True)
15+
16+
for item in hash_list:
17+
hash_value = item['hash']
18+
file_path = os.path.join(folder_path, f'{hash_value}.json')
19+
20+
if not os.path.exists(file_path):
21+
with open(file_path, 'w') as f:
22+
json.dump(item, f)
23+
print(f"Saved {file_path}")
24+
else:
25+
print(f"Failed to retrieve data. Status code: {response.status_code}")

0 commit comments

Comments
 (0)