-
Notifications
You must be signed in to change notification settings - Fork 15
53 lines (46 loc) · 1.67 KB
/
testnet_deploy.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
name: Testnet deployment
on:
push:
branches:
- testnet
jobs:
deploy:
runs-on: ubuntu-latest
env:
SSH_HOST: sepolia.api.starknet.id
SSH_USER: ubuntu
REPO_PATH: '~/api.starknet.id'
AWS_PATH: 'lfg-labs/api.starknet.id/sepolia'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'eu-west-3'
steps:
- name: Setting up SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Remote deployment
run: |
ssh -o StrictHostKeyChecking=no -T $SSH_USER@$SSH_HOST << EOF
export REPO_PATH=$REPO_PATH
# Configure AWS CLI
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set default.region $AWS_DEFAULT_REGION
if [ -d "\$REPO_PATH/.git" ]; then
echo "Repository exists, pulling changes..."
cd \$REPO_PATH
sudo docker-compose down
git pull
else
echo "Repository doesn't exist, cloning..."
mkdir -p \$REPO_PATH
git clone [email protected]:starknet-id/api.starknet.id.git \$REPO_PATH
cd \$REPO_PATH
fi
# Use AWS CLI to copy configuration files from S3
sudo chown -R \$SSH_USER:\$SSH_USER \$REPO_PATH
sudo chmod -R 755 \$REPO_PATH
aws s3 cp s3://$AWS_PATH/ \$REPO_PATH --recursive
sudo docker-compose up --build -d
EOF