Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy Callhome Service

on:
workflow_run:
workflows: ["Publish Docker image"]
types:
- completed

jobs:
deploy:
Comment thread
SammyOina marked this conversation as resolved.
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
Comment thread
SammyOina marked this conversation as resolved.
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v1.2.2
with:
host: ${{ secrets.SERVER_IP }}
username: root
Comment thread
SammyOina marked this conversation as resolved.
key: ${{ secrets.SERVER_KEY }}
command_timeout: 30m
script: |
TARGET_DIR="callhome"

if [ ! -d "$TARGET_DIR" ]; then
echo "Directory $TARGET_DIR does not exist. Cloning..."
git clone https://github.com/supermq/callhome.git $TARGET_DIR || exit 1
fi

cd $TARGET_DIR
Comment thread
SammyOina marked this conversation as resolved.

# Fetch latest changes
git fetch origin main || exit 1

CURRENT_HASH=$(git rev-parse HEAD)

# Pull latest changes
git pull origin main || exit 1

Comment thread
SammyOina marked this conversation as resolved.
# Check if docker/certbot/init-letsencrypt.sh changed in the range
CHANGED_FILES=$(git diff --name-only $CURRENT_HASH HEAD)

if echo "$CHANGED_FILES" | grep -q "docker/certbot/init-letsencrypt.sh"; then
echo "init-letsencrypt.sh has changed. Running script..."
echo "y" | ./docker/certbot/init-letsencrypt.sh
Comment thread
SammyOina marked this conversation as resolved.
else
echo "init-letsencrypt.sh has not changed. Skipping."
fi

docker compose -f docker/docker-compose.yml pull || exit 1

# Restart services
docker compose -f docker/docker-compose.yml down || exit 1
docker compose -f docker/docker-compose.yml up -d || exit 1

Comment thread
SammyOina marked this conversation as resolved.
# Cleanup
docker system prune -a -f
Comment thread
SammyOina marked this conversation as resolved.