-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (95 loc) · 3.1 KB
/
fetch-data.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
87
88
89
90
91
92
93
94
95
96
97
name: Data Fetching Processing
on:
schedule:
- cron: "30 20 * * *"
workflow_dispatch:
jobs:
Fetch-Process-Data:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
ref: data-generation
- name: Setup Python environment
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.txt
- name: Fetching & Processing resources
run: |
python ./main.py
- name: Update MD5
run: md5sum data_full.json | cut -f1 -d ' ' | tr -d $'\n' > checksum.md5
- name: Update Data Length
run: |
du -sb data.json | cut -f -1 > size.dat
du -sb data_full.json | cut -f -1 > size_full.dat
- name: GZip Data
run: |
gzip -k -f -9 data.json
gzip -k -f -9 data_full.json
- name: Update GZip Data Length
run: |
du -sb data.json.gz | cut -f -1 > size.gz.dat
du -sb data_full.json.gz | cut -f -1 > size_full.gz.dat
- name: Update resources
uses: test-room-7/action-update-file@v1
with:
file-path: |
data.json
data_formatted.json
data_full.json
data_full_formatted.json
checksum.md5
size.dat
data.json.gz
size.gz.dat
size_full.dat
data_full.json.gz
size_full.gz.dat
last_updated.txt
commit-msg: Update resources
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: data
- name: Group resources to folder
run: |
mkdir data
mv data.json data/
mv data_formatted.json data/
mv data_full.json data/
mv data_full_formatted.json data/
mv checksum.md5 data/
mv size.dat data/
mv data.json.gz data/
mv size.gz.dat data/
mv size_full.dat data/
mv data_full.json.gz data/
mv size_full.gz.dat data/
mv last_updated.txt data/
- name: Push to wear.hkbus.app
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_WEAR }}
with:
source-directory: 'data'
target-directory: 'data'
destination-github-username: 'hkbus'
destination-repository-name: 'wear.hkbus.app'
user-email: jamesloohp@gmail.com
target-branch: gh-pages
- name: Push to watch.hkbus.app
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY_WATCH }}
with:
source-directory: 'data'
target-directory: 'data'
destination-github-username: 'hkbus'
destination-repository-name: 'watch.hkbus.app'
user-email: jamesloohp@gmail.com
target-branch: gh-pages