-
-
Notifications
You must be signed in to change notification settings - Fork 4
48 lines (46 loc) · 1.41 KB
/
pull-sheet.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
# Auto import pipeline from Google Sheets
name: "Google Sheets Import"
on:
schedule:
- cron: "10 * * * *"
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
jobs:
import-sheet:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch, Validate and Push CSV
run: |
git repack --max-pack-size=512m -a
wget https://github.com/Clever/csvlint/releases/download/v0.3.0/csvlint-v0.3.0-linux-amd64.tar.gz
tar zxvf csvlint-v0.3.0-linux-amd64.tar.gz --strip-components 1
wget -O src/data/devices.csv "${{ secrets.DeviceSheetUrl }}"
./csvlint src/data/devices.csv || exit 1
if [ -z "$(git diff src/data)" ]; then
echo "No diffs to push!"
exit 0
fi
git config --local user.name "Data importer[bot]"
git config --local user.email "data-importer[bot]@users.noreply.github.com"
git add src/data
git commit -m "Updating datasets"
npm i
npm run buildDeviceLog
if [ ! -z "$(git diff src/data)" ]; then
git add src/data
git commit -m "Updating device log"
fi
git push