diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7e30758..81320a2a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,3 +56,9 @@ jobs: file: ./keylistCron/Dockerfile push: true tags: commerceblockx/keylist-cronjob:latest + env: + DB_HOST: ${{ secrets.DB_HOST }} + DB_PORT: ${{ secrets.DB_PORT }} + DB_NAME: ${{ secrets.DB_NAME }} + DB_USER: ${{ secrets.DB_USER }} + DB_PASSWORD: ${{ secrets.DB_PASSWORD }} diff --git a/keylistCron/Dockerfile b/keylistCron/Dockerfile index d1c5089f..1bf53ecd 100644 --- a/keylistCron/Dockerfile +++ b/keylistCron/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:latest -RUN apk update && apk add --no-cache curl postgresql-client +RUN apk update && apk add --no-cache curl postgresql-client jq WORKDIR /app COPY ../keylistCron/send_commitment.sh . diff --git a/keylistCron/send_commitment.sh b/keylistCron/send_commitment.sh index 922b355b..2f097ae6 100644 --- a/keylistCron/send_commitment.sh +++ b/keylistCron/send_commitment.sh @@ -1,8 +1,8 @@ #!/bin/bash # Fetch keylist JSON from the provided URL -KEYLIST_URL="http://45.77.225.72:32450/info/keylist" -KEYLIST_JSON=$(curl -sSL "$KEYLIST_URL") +KEYLIST_URL="https://api.mercurywallet.io/info/keylist" +KEYLIST_JSON=$(curl -sSL "$KEYLIST_URL" | jq -r '.list_keyinfo') # Check if the GET request was successful if [[ $? -ne 0 ]]; then @@ -39,7 +39,12 @@ fi echo "Keylist $KEYLIST_HASH attestation completed successfully!" # Connect to the database and save the keylist JSON -PG_COMMAND="psql -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c \"INSERT INTO keylist (json_data) VALUES ('$KEYLIST_JSON');\"" +PG_COMMAND="PGPASSWORD=\"$DB_PASSWORD\" psql -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c \" + CREATE TABLE IF NOT EXISTS keylist_info ( + json_data json NOT NULL + ); + INSERT INTO keylist_info (json_data) VALUES ('$KEYLIST_JSON'); + \"" # Execute the PostgreSQL command eval "$PG_COMMAND"