Skip to content

Update-Waypoints #25114

Update-Waypoints

Update-Waypoints #25114

name: Update-Waypoints
# Run this workflow once a week at Sunday
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
jobs:
create-json:
name: Creates or updates waypoints.json
runs-on: ubuntu-22.04
env:
WAYPOINTS_DEST: "public/auto_generated_waypoints.json"
defaults:
run:
shell: bash
steps:
- name: Prepare environment
run: |
sudo apt-get --yes update
sudo apt-get --yes install python3-pip
sudo pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
sudo pip3 install -U pip setuptools
sudo pip3 install --use-pep517 googlemaps
sudo pip3 install pandas
- name: Checkout code
uses: actions/checkout@v4
- name: Set environment variables and update waypoints.json
run: |
export SPREADSHEET_ID="$GOOGLE_SPREADSHEET_ID"
export GEOCODING_API_KEY="$GOOGLE_GEOCODING_API_KEY"
TEMP_DIR=$(mktemp -d)
export CREDENTIALS_PATH="$TEMP_DIR"/credentials.json
echo "$GOOGLE_SERVICE_ACCOUNT" > $CREDENTIALS_PATH
python3 update_waypoints.py
env:
GOOGLE_SPREADSHEET_ID: ${{ secrets.GOOGLE_SPREADSHEET_ID }}
GOOGLE_GEOCODING_API_KEY: ${{ secrets.GOOGLE_GEOCODING_API_KEY }}
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
- name: Add and commit changes to waypoints.json
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if ! git diff --quiet "$WAYPOINTS_DEST"; then
git add $WAYPOINTS_DEST
git commit -m "Update waypoints.json"
else
echo "No changes to commit."
fi
- name: Push changes to repository
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
# - name: Add and commit changes to waypoints.json
# if: ${{ env.changes_exist == 'true' || env.already_exists == 'false' }}
# run: |
# git config --local user.email "action@github.com"
# git config --local user.name "GitHub Action"
# git add src/waypoints.json
# git add public/static/waypoints.json
# git commit -m "Update waypoints.json with new rows"
# - name: Push changes to repository
# if: ${{ env.changes_exist == 'true' || env.already_exists == 'false' }}
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}