diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d0aeaeb --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: Auto Deploy HRISMP ML API + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: self-hosted + + steps: + - name: Deployment Logic HRISMP ML API + run: | + cd /www/wwwroot/joule/mp-hris-ml + + OLD_COMMIT=$(git rev-parse HEAD) + + git fetch --all + git reset --hard origin/main + + NEW_COMMIT=$(git rev-parse HEAD) + + if [ "$OLD_COMMIT" != "$NEW_COMMIT" ]; then + echo " Update detected. Rebuilding ML API..." + docker compose down + docker compose up -d --build + docker image prune -f + else + echo "No changes detected. Skip rebuild." + fi + + echo "Checking ML API health..." + sleep 5 + curl -f http://127.0.0.1:8002/health || exit 1 \ No newline at end of file