Skip to content

Commit

Permalink
add hasura grahpql integration
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMandal0rian committed Aug 6, 2024
1 parent 0ff6921 commit e5fa002
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/gh-deploy-micro-squids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy Docker Compose for Micro Squids on main
on:
push:
branches:
- main
- production
paths:
- "indexers/general-squid/**"
- "indexers/rewards-squid/**"
Expand Down Expand Up @@ -34,6 +34,7 @@ jobs:
- name: Deploy with Docker Compose
env:
SSH_USER: ${{ secrets.SSH_USER }}
HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.SQUID_HOST }} >> ~/.ssh/known_hosts
Expand All @@ -45,6 +46,15 @@ jobs:
git pull
fi
git checkout ${BRANCH_NAME}
# Check if HASURA_GRAPHQL_ADMIN_SECRET already exists in .env
if ! grep -q 'HASURA_GRAPHQL_ADMIN_SECRET=' .env 2>/dev/null; then
echo 'HASURA_GRAPHQL_ADMIN_SECRET=${HASURA_GRAPHQL_ADMIN_SECRET}' >> .env
fi
# Update the HASURA_GRAPHQL_ADMIN_SECRET value
sed -i 's/^HASURA_GRAPHQL_ADMIN_SECRET=.*/HASURA_GRAPHQL_ADMIN_SECRET=${HASURA_GRAPHQL_ADMIN_SECRET}/' .env
docker-compose -f docker-compose-all-squids.yml pull
docker-compose -f docker-compose-all-squids.yml up -d
"
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/gh-deploy-monolith-squid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy Docker Compose for Micro Squids on main

on:
push:
branches:
- production
paths:
- "indexers/general-squid/**"
- "indexers/rewards-squid/**"
- "indexers/accounts-squid/**"

env:
DOCKER_HOST: ssh://${{ secrets.SSH_USER }}@${{ secrets.SQUID_HOST }}
DEPLOY_PATH: /home/ubuntu/squids/astral
BRANCH_NAME: ${{ github.ref == 'refs/heads/main' && 'main' || github.ref }}

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install SSH key
uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 # v0.9.0
with:
ssh-private-key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }}

- name: Add SSH host key fingerprint
run: |
ssh-keyscan -H ${{ secrets.SQUID_HOST }} >> ~/.ssh/known_hosts
- name: Deploy with Docker Compose
env:
SSH_USER: ${{ secrets.SSH_USER }}
HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.SQUID_HOST }} >> ~/.ssh/known_hosts
ssh ${SSH_USER}@${{ secrets.SQUID_HOST }} "
if [ ! -d ${DEPLOY_PATH} ]; then
git clone https://github.com/autonomys/astral.git ${DEPLOY_PATH}
else
cd ${DEPLOY_PATH}
git pull
fi
git checkout ${BRANCH_NAME}
# Check if HASURA_GRAPHQL_ADMIN_SECRET already exists in .env
if ! grep -q 'HASURA_GRAPHQL_ADMIN_SECRET=' .env 2>/dev/null; then
echo 'HASURA_GRAPHQL_ADMIN_SECRET=${HASURA_GRAPHQL_ADMIN_SECRET}' >> .env
fi
# Update the HASURA_GRAPHQL_ADMIN_SECRET value
sed -i 's/^HASURA_GRAPHQL_ADMIN_SECRET=.*/HASURA_GRAPHQL_ADMIN_SECRET=${HASURA_GRAPHQL_ADMIN_SECRET}/' .env
docker-compose -f docker-compose-all-squids.yml pull
docker-compose -f docker-compose-all-squids.yml up -d
"
- name: Notify on failure
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job
author_name: Deployment failed
mention: here
if_mention: failure,cancelled
job_name: Deploy Docker Compose for Micro Squids on staging
channel: alerts
icon_emoji: ":github:"
3 changes: 3 additions & 0 deletions indexers/squid-blockexplorer/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ GQL_PORT=4350
ARCHIVE_ENDPOINT=
CHAIN_RPC_ENDPOINT=
SQUID_GRAPHQL_ENDPOINT=
HASURA_GRAPHQL_ENDPOINT=
HASURA_GQL_PORT=8080
HASURA_GRAPHQL_ADMIN_SECRET="myadminsecretkey"
25 changes: 25 additions & 0 deletions indexers/squid-blockexplorer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,30 @@ services:
environment:
POSTGRES_DB: squid
POSTGRES_PASSWORD: squid
POSTGRES_USER: postgres
ports:
- "${DB_PORT}:5432"

graphql-engine:
image: hasura/graphql-engine:v2.40.0
depends_on:
- "postgres"
restart: always
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://\${POSTGRES_USER}:\${POSTGRES_PASSWORD}@db:5432/\${POSTGRES_DB}
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
## uncomment next line to set an admin secret
HASURA_GRAPHQL_ADMIN_SECRET: \${HASURA_GRAPHQL_ADMIN_SECRET}
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: user
HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true"
ports:
- "${HASURA_GQL_PORT}:8080"
command:
- graphql-engine
- serve

0 comments on commit e5fa002

Please sign in to comment.