Skip to content

.github/workflows/deploy_monitor.yml #28

.github/workflows/deploy_monitor.yml

.github/workflows/deploy_monitor.yml #28

name: Server Monitoring
on:
schedule:
# 매일 UTC 시간 기준 00:00에 실행 (현지 시간에 맞게 조정해야 할 수 있음)
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
monitor:
runs-on: ubuntu-latest
steps:
- name: Check Server Status
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
echo "Checking Docker containers status..."
cd ${{secrets.PATH}}
FAILED_CONTAINERS=$(docker-compose -f docker-compose.yml ps -q | xargs docker inspect --format '{{if not .State.Running}} {{.Name}} {{end}}')
if [ -n "$FAILED_CONTAINERS" ]; then
echo "These containers are not running:$FAILED_CONTAINERS"
exit 1
else
echo "All containers are running as expected."
fi
- name: Result
if: always()
run: echo "Containers check completed successfully."