-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (48 loc) · 1.83 KB
/
update.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
name: Update data
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
# push:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Check CSV hash
id: get-hash
run:
echo "::set-output name=remote::$(curl -skL "https://docs.google.com/spreadsheets/d/e/2PACX-1vQ3jzuTRwdCbmbi4NlJRFByXt_iebonhBtZs8skeUe-dQY6bDQYCG39oIKK2VEnh8jhLcBtGSp7hAjD/pub?gid=1462243235&single=true&output=csv" > download.csv && sha1sum download.csv | cut -f 1 -d " ")"
shell: bash
- uses: actions/cache@v2
id: cache
with:
path: ~/.cache
key: ${{ runner.os }}-${{ steps.get-hash.outputs.remote }}
- name: Installing miller
if: steps.cache.outputs.cache-hit != 'true'
run: |-
sudo apt-get install miller
- name: Download and update CSV data
if: steps.cache.outputs.cache-hit != 'true'
run: |
mlr --csv cut -x -f provincia,ordinanza,durata_effettiva,no_scuola then \
cut -o -f pro_com,comune,zona,data_inizio,data_fine,id_ordinanza,nro_ordinanza,data_ordinanza,PDF,nro_pgg,link_ordinanza,note download.csv > data.csv
echo "Dati aggiornati!"
- name: Remove temp files
run:
rm download.csv
- name: Build JSON
if: steps.cache.outputs.cache-hit != 'true'
run: |
mlr --icsv --ojson --jlistwrap --jvstack cat data.csv > data.json
echo "JSON creato!"
- name: Update Repository
run: |-
git config user.name "autoupdate"
git config user.email "actions@users.noreply.github.com"
git add -A
timestamp=$(date --iso-8601=seconds)
git commit -m "update: ${timestamp}" || exit 0
git push