Skip to content

Commit

Permalink
Add CI to crawler automatic
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Feb 23, 2021
1 parent afde1b5 commit a97d33e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

name: Crawler NSYSU Bus
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '*/5 * * * *'
jobs:
curl:
name: Crawler and Publish
runs-on: ubuntu-latest
steps:
- name: Set checkout
uses: actions/checkout@v2
- name: mkdir dir
run: mkdir build
- run: export time=$(($(date +%s%N)/1000))
- run: echo $time
- name: Instal CURL
run: sudo apt install -y curl
- name: Use curl download zh
run: curl https://ibus.nsysu.edu.tw/API/RoutePath.aspx\?$time\&T=SC -o tmp_zh.json
- name: Use curl download en
run: curl 'https://ibus.nsysu.edu.tw/API/RoutePath.aspx?&C=en&T=SC' -o tmp_en.json
- run: rm -f bus_info_data_zh.json
- name: Use JD
uses: r26d/jq-action@master
with:
cmd: jq -n env
- name: merge zh json
run: jq -s '.[0] + .[1]' bus_zh.json tmp_zh.json >> build/bus_info_data_zh.json
- name: merge en json
run: jq -s '.[0] + .[1]' bus_en.json tmp_en.json >> build/bus_info_data_en.json
- name: Deploy
run: |
cd build
git init
git config user.name "CI"
git config user.email "flutter-ci@github.com"
git remote add secure-origin https://${{ secrets.ACCESS_TOKEN }}@github.com/abc873693/nsysu-bus-test.git
git checkout -b gh-pages
git add .
git commit -m "Updated site"
git push --force secure-origin gh-pages
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.DS_Store
1 change: 1 addition & 0 deletions bus_en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"CarID":"EAA-902,EAA-903,EAL-0907,EAL-0909,","StopName":"","RouteID":50,"NameEn":"50 Wufu Main Line","isOpenData":"Y","DepartureEn":"Gushan Ferry Pier Station","DestinationEn":"Jianjun Station (MRT Weiwuying Station)"},{"CarID":"089-XH,099-XH,","StopName":"","RouteID":99,"NameEn":"NO.99","isOpenData":"Y","DepartureEn":"Cihde Temple","DestinationEn":"Former Banana Warehouse"},{"CarID":"057-FT,060-FT,129-FT,200-FV,EAL-0928,","StopName":"","RouteID":219,"NameEn":"219 A","isOpenData":"Y","DepartureEn":"Jiachang Station","DestinationEn":"Dajhih Rd. (Guangrong Elementary School)"},{"CarID":"529-FP,911-V2,","StopName":"","RouteID":248,"NameEn":"248","isOpenData":"Y","DepartureEn":"Binhai 2nd Rd.","DestinationEn":"Jianjun Station (MRT Weiwuying Station)"},{"CarID":"193-FV,532-FP,","StopName":"","RouteID":852,"NameEn":"Red 52","isOpenData":"Y","DepartureEn":"National Sun Yat-sen University","DestinationEn":"TRA New Zuoying Station"},{"CarID":"107-V3,","StopName":"","RouteID":901,"NameEn":"Orange 1 A","isOpenData":"Y","DepartureEn":"Administration Square","DestinationEn":"MRT Sizihwan Station Exit 1"},{"CarID":"667-FP,672-FP,","StopName":"","RouteID":2482,"NameEn":"248(Interval)","isOpenData":"Y","DepartureEn":"Binhai 2nd Rd.","DestinationEn":"Kaohsiung Train Station (MRT Kaohsiung Main Station)"},{"CarID":"252-FN,","StopName":"","RouteID":9012,"NameEn":"Orange 1 C","isOpenData":"Y","DepartureEn":"College of Liberal Arts","DestinationEn":"MRT Sizihwan Station Exit 2"}]
1 change: 1 addition & 0 deletions bus_zh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"CarID":"EAA-901,EAL-0901,EAL-0903,EAL-0907,EAL-0926,","StopName":"","RouteID":50,"Name":"50五福幹線","isOpenData":"Y","Departure":"鼓山輪渡站","Destination":"建軍站(捷運衛武營站)"},{"CarID":"063-XH,089-XH,","StopName":"","RouteID":99,"Name":"99","isOpenData":"Y","Departure":"慈德堂","Destination":"香蕉棚"},{"CarID":"073-FT,139-V3,EAL-0928,EAL-0952,","StopName":"","RouteID":219,"Name":"219 A","isOpenData":"Y","Departure":"大智路(光榮國小)","Destination":"加昌站"},{"CarID":"671-FP,911-V2,","StopName":"","RouteID":248,"Name":"248","isOpenData":"Y","Departure":"濱海二路","Destination":"捷運衛武營站"},{"CarID":"192-FV,193-FV,","StopName":"","RouteID":852,"Name":"紅52","isOpenData":"Y","Departure":"中山大學","Destination":"台鐵新左營站"},{"CarID":"771-FP,","StopName":"","RouteID":901,"Name":"橘1A","isOpenData":"Y","Departure":"中山大學行政大樓","Destination":"捷運西子灣1號出口"},{"CarID":"667-FP,","StopName":"","RouteID":2482,"Name":"248區間車","isOpenData":"Y","Departure":"濱海二路","Destination":"高雄火車站(捷運高雄車站)"},{"CarID":"252-FN,","StopName":"","RouteID":9012,"Name":"橘1C","isOpenData":"Y","Departure":"文學院","Destination":"捷運西子灣2號出口"}]

0 comments on commit a97d33e

Please sign in to comment.