forked from zoningatlas/web-map
-
-
Notifications
You must be signed in to change notification settings - Fork 11
116 lines (109 loc) · 3.89 KB
/
spreadsheet.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Pull and Validate Spreadsheet Data
env:
SPREADSHEET_ID: 1YGt_Y70oy6qc09ZZ7kip9DM2JGtRC2fAHxi6JXOIsSk
on:
workflow_dispatch: {}
schedule:
- cron: '0 10 * * *'
jobs:
Pull-And-Merge-Spreadsheet-Data:
runs-on: ubuntu-latest
steps:
- name: Pulling Maui
working-directory: ${{ runner.temp }}
env:
MAUI_SHEET_ID: '987737350'
MAUI_FILE_NAME: 'maui.csv'
run: |
wget "${{ format('https://docs.google.com/spreadsheets/d/{0}/export?format=csv&gid={1}', '$SPREADSHEET_ID', '$MAUI_SHEET_ID') }}" -O $MAUI_FILE_NAME
- name: Pulling Honolulu (Oahu)
working-directory: ${{ runner.temp }}
env:
HONOLULU_SHEET_ID: '448730928'
HONOLULU_SHEET_NAME: 'honolulu.csv'
run: |
wget "${{ format('https://docs.google.com/spreadsheets/d/{0}/export?format=csv&gid={1}', '$SPREADSHEET_ID', '$HONOLULU_SHEET_ID') }}" -O $HONOLULU_SHEET_NAME
- name: Pulling Hawaii (Big Island)
working-directory: ${{ runner.temp }}
env:
HAWAII_SHEET_ID: '835193382'
HAWAII_SHEET_NAME: 'hawaii.csv'
run: |
wget "${{ format('https://docs.google.com/spreadsheets/d/{0}/export?format=csv&gid={1}', '$SPREADSHEET_ID', '$HAWAII_SHEET_ID') }}" -O $HAWAII_SHEET_NAME
- name: Pulling Kauai
working-directory: ${{ runner.temp }}
env:
KAUAI_SHEET_ID: '1657052642'
KAUAI_SHEET_NAME: 'kauai.csv'
run: |
wget "${{ format('https://docs.google.com/spreadsheets/d/{0}/export?format=csv&gid={1}', '$SPREADSHEET_ID', '$KAUAI_SHEET_ID') }}" -O $KAUAI_SHEET_NAME
- name: Merge Island CSVs
working-directory: ${{ runner.temp }}
run: |
head -n 1 maui.csv > hawaii-zoning-data.csv && tail -n+2 -q *.csv >> hawaii-zoning-data.csv
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: hawaii-zoning-data.csv
path: ${{ runner.temp }}/hawaii-zoning-data.csv
Validate-Data:
needs: Pull-And-Merge-Spreadsheet-Data
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install csvkit
run: |
pip install csvkit
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: hawaii-zoning-data.csv
- name: Validate Data # Not doing any real validation, just outputting csvclean results to detect any surface problems
run: |
csvclean -n hawaii-zoning-data.csv
Validate-CSV:
needs: Validate-Data
runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v3'
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install petl
working-directory: data-pipeline/csv-validation
run: |
pip install -r ./requirements.txt
- name: Run Validation
working-directory: data-pipeline/csv-validation
run: |
python validation.py
Commit-Data:
needs: Validate-CSV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: hawaii-zoning-data.csv
- name: Get current date
run: echo "NOW=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Move Artifact
run:
mv hawaii-zoning-data.csv data/
- name: Commit to repo
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "there are changes to commit";
else
exit 0;
fi
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add data/hawaii-zoning-data.csv
git commit -m "Spreadsheet data update ${{ env.NOW }}"
git push