From a97d33ef282272c16aa35c209c116369f16f35d4 Mon Sep 17 00:00:00 2001 From: RainVisitor Date: Tue, 23 Feb 2021 20:09:00 +0800 Subject: [PATCH] Add CI to crawler automatic --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ bus_en.json | 1 + bus_zh.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 bus_en.json create mode 100644 bus_zh.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..678725886 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9bea4330f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/bus_en.json b/bus_en.json new file mode 100644 index 000000000..ec765ef25 --- /dev/null +++ b/bus_en.json @@ -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"}] \ No newline at end of file diff --git a/bus_zh.json b/bus_zh.json new file mode 100644 index 000000000..cf7b04665 --- /dev/null +++ b/bus_zh.json @@ -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號出口"}] \ No newline at end of file