-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add auto testnet deployment workflow
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |