Skip to content

Commit 071501a

Browse files
committed
use different method to get db creds in deploy action
1 parent 92934c7 commit 071501a

2 files changed

Lines changed: 21 additions & 27 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

docs/workshop_setup.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
from workshop_setup import setup
66
config = setup()
77
8-
# Access database configuration
9-
print(config['pghost'])
10-
print(config['pgdatabase'])
11-
128
Note: API endpoints are already configured in the environment via the start script.
139
"""
1410

@@ -82,8 +78,6 @@ def setup(token: Optional[str] = None):
8278
os.environ["PGPASSWORD"] = config["pgpassword"]
8379

8480
print("\n✓ Database credentials configured successfully!")
85-
print(f" Host: {config['pghost']}")
86-
print(f" Database: {config['pgdatabase']}")
8781

8882
return config
8983

0 commit comments

Comments
 (0)