File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 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 }}
Original file line number Diff line number Diff line change 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 } " )
You can’t perform that action at this time.
0 commit comments