Skip to content

pumps_cron

pumps_cron #192

Workflow file for this run

name: Update Pumps in Supabase Storage
on:
workflow_dispatch:
repository_dispatch:
# This action can be triggered via Github API webook (see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#repository_dispatch)
types: [pumps_cron]
defaults:
run:
shell: bash
working-directory: pumps-harvester
jobs:
collect_pumps:
environment: "${{ github.event.client_payload.environment }}"
runs-on: ubuntu-latest
name: A job to aggregate pumps data from open street maps and push to GDK Supabase
steps:
- name: Get the source
uses: actions/checkout@v4
- name: build the harvester
run: docker build --tag "${GITHUB_REPOSITORY}:${GITHUB_REF##*/}" .
- name: run the harvester
run: docker run -v /tmp:/tmp "${GITHUB_REPOSITORY}:${GITHUB_REF##*/}" /tmp/out.json -q "${{ vars.OSM_PUMPS_QUERY }}"
- name: Upload file to supabase
run: |
getStatusCode=$(curl -s -o /dev/null -w "%{http_code}" \
-X GET \
${{ vars.SUPABASE_URL }}/storage/v1/object/public/${{ vars.SUPABASE_DATA_ASSETS_BUCKET }}/pumps.geojson)
if [ "$getStatusCode" = "200" ]; then
putStatusCode=$(curl -s -o /dev/null -w "%{http_code}" \
-X PUT \
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}" \
-H "Content-Type: application/geo+json" \
-d "@/tmp/out.json" \
${{ vars.SUPABASE_URL }}/storage/v1/object/${{ vars.SUPABASE_DATA_ASSETS_BUCKET }}/pumps.geojson)
if [ "$putStatusCode" = "200" ]; then
echo "Uploading to Supabase successful"
else
echo "Uploading to Supabase failed"
exit 1
fi
else
postStatusCode=$(curl -s -o /dev/null -w "%{http_code}" \
-X POST \
-H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}" \
-H "Content-Type: application/geo+json" \
-d "@/tmp/out.json" \
${{ vars.SUPABASE_URL }}/storage/v1/object/${{ vars.SUPABASE_DATA_ASSETS_BUCKET }}/pumps.geojson)
if [ "$postStatusCode" = "200" ]; then
echo "Uploading to Supabase successful"
else
echo "Uploading to Supabase failed"
exit 1
fi
fi