-
Notifications
You must be signed in to change notification settings - Fork 33
54 lines (52 loc) · 2.38 KB
/
pumps.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
49
50
51
52
53
54
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