forked from simonw/sf-tree-history
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed643fe
commit 2817a0e
Showing
1 changed file
with
28 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,45 +4,36 @@ on: | |
push: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '21 11 * * *' | ||
- cron: "21 11 * * *" | ||
|
||
jobs: | ||
scheduled: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out this repo | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- uses: actions/cache@v2 | ||
name: Configure pip caching | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install Python dependencies | ||
run: |- | ||
pip install -r requirements.txt | ||
- name: Fetch latest data | ||
run: |- | ||
cp Street_Tree_List.csv Street_Tree_List-old.csv | ||
curl -o Street_Tree_List-unsorted.csv "https://data.sfgov.org/api/views/tkzw-k3nq/rows.csv?accessType=DOWNLOAD" | ||
# Remove heading line and use it to start a new file | ||
head -n 1 Street_Tree_List-unsorted.csv > Street_Tree_List.csv | ||
# Sort all but the first line and append to that file | ||
tail -n +2 "Street_Tree_List-unsorted.csv" | sort >> Street_Tree_List.csv | ||
# Generate commit message using csv-diff | ||
csv-diff Street_Tree_List-old.csv Street_Tree_List.csv --key=TreeID --singular=tree --plural=trees > message.txt | ||
- name: Commit and push if it changed | ||
run: |- | ||
git config user.name "Automated" | ||
git config user.email "[email protected]" | ||
git add Street_Tree_List.csv | ||
timestamp=$(date -u) | ||
git commit -F message.txt || exit 0 | ||
git push | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Setup Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.11.x" | ||
- name: Install Python dependencies | ||
run: | | ||
uv pip install -r requirements.txt --system | ||
- name: Fetch latest data | ||
run: | | ||
cp Street_Tree_List.csv Street_Tree_List-old.csv | ||
curl -o Street_Tree_List-unsorted.csv "https://data.sfgov.org/api/views/tkzw-k3nq/rows.csv?accessType=DOWNLOAD" | ||
# Remove heading line and use it to start a new file | ||
head -n 1 Street_Tree_List-unsorted.csv > Street_Tree_List.csv | ||
# Sort all but the first line and append to that file | ||
tail -n +2 "Street_Tree_List-unsorted.csv" | sort >> Street_Tree_List.csv | ||
# Generate commit message using csv-diff | ||
csv-diff Street_Tree_List-old.csv Street_Tree_List.csv --key=TreeID --singular=tree --plural=trees > message.txt | ||
- name: Commit and push if it changed | ||
run: |- | ||
git config user.name "Automated" | ||
git config user.email "[email protected]" | ||
git add Street_Tree_List.csv | ||
timestamp=$(date -u) | ||
git commit -F message.txt || exit 0 | ||
git push |