@@ -79,33 +79,26 @@ jobs:
7979
8080 - name : Load Workshop Data - Ecoregions
8181 run : |
82- # Get database credentials from CloudFormation
83- PGSTAC_SECRET_ARN=$(aws cloudformation describe-stacks \
84- --stack-name ${{ vars.PROJECT_ID }} \
85- --query "Stacks[0].Outputs[?OutputKey=='PgstacSecret'].OutputValue" \
86- --output text)
87-
88- PGSTAC_SECRET_VALUE=$(aws secretsmanager get-secret-value \
89- --secret-id "$PGSTAC_SECRET_ARN" \
90- --query "SecretString" \
91- --output text)
92-
93- export PGHOST=$(echo "$PGSTAC_SECRET_VALUE" | jq -r '.host')
94- export PGPORT=$(echo "$PGSTAC_SECRET_VALUE" | jq -r '.port')
95- export PGDATABASE=$(echo "$PGSTAC_SECRET_VALUE" | jq -r '.dbname')
96- export PGUSER=$(echo "$PGSTAC_SECRET_VALUE" | jq -r '.username')
97- export PGPASSWORD=$(echo "$PGSTAC_SECRET_VALUE" | jq -r '.password')
82+ # Get database credentials from config endpoint
83+ CONFIG_URL="https://${{ vars.PROJECT_ID }}-config.eoapi.dev"
84+
85+ echo "Fetching database credentials from: $CONFIG_URL"
86+ CONFIG_RESPONSE=$(curl -s -H "Authorization: Bearer ${{ vars.WORKSHOP_TOKEN }}" "$CONFIG_URL")
87+
88+ export PGHOST=$(echo "$CONFIG_RESPONSE" | jq -r '.pghost')
89+ export PGPORT=$(echo "$CONFIG_RESPONSE" | jq -r '.pgport')
90+ export PGDATABASE=$(echo "$CONFIG_RESPONSE" | jq -r '.pgdatabase')
91+ export PGUSER=$(echo "$CONFIG_RESPONSE" | jq -r '.pguser')
92+ export PGPASSWORD=$(echo "$CONFIG_RESPONSE" | jq -r '.pgpassword')
93+
94+ echo "✓ Database credentials fetched successfully"
9895
9996 # Install PostgreSQL client
10097 sudo apt-get update
10198 sudo apt-get install -y postgresql-client
10299
103100 # Create schema and prepare for data
104- PGPASSWORD="$PGPASSWORD" psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" \
105- -c "CREATE SCHEMA IF NOT EXISTS features;"
106-
107- PGPASSWORD="$PGPASSWORD" psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" \
108- -c "DROP TABLE IF EXISTS features.ecoregions;"
101+ psql -c "CREATE SCHEMA IF NOT EXISTS features; DROP TABLE IF EXISTS features.ecoregions;"
109102
110103 # Load data using GDAL
111104 docker run --rm ghcr.io/osgeo/gdal:alpine-small-latest ogr2ogr -f "PostgreSQL" \
@@ -118,3 +111,10 @@ jobs:
118111 -nlt PROMOTE_TO_MULTI \
119112 -t_srs EPSG:4326 \
120113 -simplify 0.001
114+
115+ # load a STAC collection
116+ curl https://stac.maap-project.org/collections/glad-global-forest-change-1.11 > /tmp/collection.json
117+ uvx rustac search https://stac.maap-project.org /tmp/items.ndjson --collections glad-global-forest-change-1.11 --limit 100 -o ndjson
118+
119+ uvx --from pypgstac[psycopg]==${{ vars.PGSTAC_VERSION }} pypgstac load collections /tmp/collection.json --method=upsert
120+ uvx --from pypgstac[psycopg]==${{ vars.PGSTAC_VERSION }} pypgstac load items /tmp/items.ndjson --method=upsert
0 commit comments