pumps_cron #316
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
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] | |
jobs: | |
collect_pumps: | |
# Using the payload of the repository_dispatch webhook to specify the environment | |
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: Pumps data generate step | |
id: pumps | |
uses: technologiestiftung/[email protected] | |
with: | |
outfile-path: "public/data/pumps.geojson" | |
- name: File output | |
run: echo "The file was written to ${{ steps.pumps.outputs.file }}" | |
- name: Upload file to supabase | |
run: | | |
getStatusCode=$(curl -s -o /dev/null -w "%{http_code}" \ | |
-X GET \ | |
${{ vars.SUPABASE_URL }}/storage/v1/object/info/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 "@${{ steps.pumps.outputs.file }}" \ | |
${{ 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 "@${{ steps.pumps.outputs.file }}" \ | |
${{ 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 |