-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ff6921
commit e5fa002
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters