Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable indexer workflow #1046

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 75 additions & 75 deletions .github/workflows/gh-deploy-subql.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
name: Deploy Subql Green (staging)
# name: Deploy Subql Green (staging)

on:
push:
branches:
- main
paths:
- "indexers/**"
env:
DOCKER_HOST: ssh://${{ secrets.SSH_USER }}@${{ secrets.SUBQL_HOST }}
DEPLOY_PATH: /home/${{ secrets.SSH_USER }}/astral
BRANCH_NAME: ${{ github.ref_name }}
# on:
# push:
# branches:
# - main
# paths:
# - "indexers/**"
# env:
# DOCKER_HOST: ssh://${{ secrets.SSH_USER }}@${{ secrets.SUBQL_HOST }}
# DEPLOY_PATH: /home/${{ secrets.SSH_USER }}/astral
# BRANCH_NAME: ${{ github.ref_name }}

jobs:
deploy:
runs-on: ubuntu-latest
# jobs:
# deploy:
# runs-on: ubuntu-latest

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

- name: Set Hasura secret
id: set_secret
run: echo "hasura_secret=${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}" >> $GITHUB_ENV
# - name: Set Hasura secret
# id: set_secret
# run: echo "hasura_secret=${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}" >> $GITHUB_ENV

- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }}
# - name: Install SSH key
# uses: webfactory/[email protected]
# with:
# ssh-private-key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }}

- name: Add SSH host key fingerprint
run: |
ssh-keyscan -H ${{ secrets.SUBQL_HOST }} >> ~/.ssh/known_hosts
# - name: Add SSH host key fingerprint
# run: |
# ssh-keyscan -H ${{ secrets.SUBQL_HOST }} >> ~/.ssh/known_hosts

- name: Deploy with Docker Compose
env:
SSH_USER: ${{ secrets.SSH_USER }}
HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
HASURA_GRAPHQL_JWT_SECRET: ${{ secrets.HASURA_GRAPHQL_JWT_SECRET }}
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.SUBQL_HOST }} >> ~/.ssh/known_hosts
ssh ${SSH_USER}@${{ secrets.SUBQL_HOST }} "
# - name: Deploy with Docker Compose
# env:
# SSH_USER: ${{ secrets.SSH_USER }}
# HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
# HASURA_GRAPHQL_JWT_SECRET: ${{ secrets.HASURA_GRAPHQL_JWT_SECRET }}
# run: |
# mkdir -p ~/.ssh
# ssh-keyscan -H ${{ secrets.SUBQL_HOST }} >> ~/.ssh/known_hosts
# ssh ${SSH_USER}@${{ secrets.SUBQL_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}
# 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}

# Securely update the .env file
if [ ! -f .env ]; then
echo 'HASURA_GRAPHQL_ADMIN_SECRET=${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}' > .env
echo 'HASURA_GRAPHQL_JWT_SECRET=${{ secrets.HASURA_GRAPHQL_JWT_SECRET }}' >> .env
else
sed -i '/^HASURA_GRAPHQL_ADMIN_SECRET=/d' .env
echo 'HASURA_GRAPHQL_ADMIN_SECRET=${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}' >> .env
sed -i '/^HASURA_GRAPHQL_JWT_SECRET=/d' .env
echo 'HASURA_GRAPHQL_JWT_SECRET=${{ secrets.HASURA_GRAPHQL_JWT_SECRET }}' >> .env
fi
# # Securely update the .env file
# if [ ! -f .env ]; then
# echo 'HASURA_GRAPHQL_ADMIN_SECRET=${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}' > .env
# echo 'HASURA_GRAPHQL_JWT_SECRET=${{ secrets.HASURA_GRAPHQL_JWT_SECRET }}' >> .env
# else
# sed -i '/^HASURA_GRAPHQL_ADMIN_SECRET=/d' .env
# echo 'HASURA_GRAPHQL_ADMIN_SECRET=${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}' >> .env
# sed -i '/^HASURA_GRAPHQL_JWT_SECRET=/d' .env
# echo 'HASURA_GRAPHQL_JWT_SECRET=${{ secrets.HASURA_GRAPHQL_JWT_SECRET }}' >> .env
# fi

export $(grep -v '^#' /home/${{ secrets.SSH_USER }}/astral/.env | xargs)
cd /home/${{ secrets.SSH_USER }}/astral/indexers
yarn build-dictionary
npx lerna run codegen
npx lerna run build
sudo docker compose -p prod-astral-indexers -f /home/${{ secrets.SSH_USER }}/astral/docker-compose.yml -f /home/${{ secrets.SSH_USER }}/astral/docker-compose.prod.yml --profile dictionary --profile task --profile taurus up -d --remove-orphans
echo 'Installation Complete'
"
# export $(grep -v '^#' /home/${{ secrets.SSH_USER }}/astral/.env | xargs)
# cd /home/${{ secrets.SSH_USER }}/astral/indexers
# yarn build-dictionary
# npx lerna run codegen
# npx lerna run build
# sudo docker compose -p prod-astral-indexers -f /home/${{ secrets.SSH_USER }}/astral/docker-compose.yml -f /home/${{ secrets.SSH_USER }}/astral/docker-compose.prod.yml --profile dictionary --profile task --profile taurus up -d --remove-orphans
# echo 'Installation Complete'
# "

- 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 Subql Green (staging)
channel: alerts
icon_emoji: ":github:"
# - 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 Subql Green (staging)
# channel: alerts
# icon_emoji: ":github:"
Loading