-
Notifications
You must be signed in to change notification settings - Fork 9
65 lines (57 loc) · 1.99 KB
/
gh-deploy-micro-squids.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Deploy Docker Compose for Micro Squids on main
on:
push:
branches:
- main
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 }}
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/subspace/astral.git ${DEPLOY_PATH}
else
cd ${DEPLOY_PATH}
git pull
fi
git checkout ${BRANCH_NAME}
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:"