initial commit #1
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
name: Automatic Deployment | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
SSH_HOST: identicon.starknet.id | |
SSH_USER: ubuntu | |
REPO_PATH: '~/identicon.starknet.id' | |
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 | |
export GIT_SSH_COMMAND='ssh -i ~/.ssh/github_read -o IdentitiesOnly=yes' | |
if [ -d "\$REPO_PATH/.git" ]; then | |
echo "Repository exists, pulling changes..." | |
cd \$REPO_PATH | |
sudo docker compose down | |
git reset --hard HEAD | |
git pull | |
else | |
echo "Repository doesn't exist, cloning..." | |
mkdir -p \$REPO_PATH | |
git clone [email protected]:starknet-id/identicon.starknet.id.git \$REPO_PATH | |
cd \$REPO_PATH | |
fi | |
sudo chown -R \$SSH_USER:\$SSH_USER \$REPO_PATH | |
sudo chmod -R 755 \$REPO_PATH | |
sudo docker compose up --build -d | |
EOF |