diff --git a/.github/workflows/deploy_monitor.yml b/.github/workflows/deploy_monitor.yml new file mode 100644 index 0000000..dc73b24 --- /dev/null +++ b/.github/workflows/deploy_monitor.yml @@ -0,0 +1,34 @@ +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..." + 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."