This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build & Deploy
|
||||
name: Deploy via Portainer
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -8,32 +8,11 @@ jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
- name: Trigger Portainer stack redeploy
|
||||
run: |
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
if [ -d "$GITHUB_WORKSPACE/.git" ]; then
|
||||
git -C "$GITHUB_WORKSPACE" fetch --all
|
||||
git -C "$GITHUB_WORKSPACE" reset --hard "$GITHUB_SHA"
|
||||
else
|
||||
git clone "http://192.168.5.171:3000/$GITHUB_REPOSITORY.git" "$GITHUB_WORKSPACE"
|
||||
git -C "$GITHUB_WORKSPACE" checkout "$GITHUB_SHA"
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "${{ secrets.PORTAINER_WEBHOOK }}")
|
||||
if [ "$HTTP_CODE" != "200" ] && [ "$HTTP_CODE" != "204" ]; then
|
||||
echo "Portainer webhook failed (HTTP $HTTP_CODE)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build image
|
||||
run: docker build -t 3d-pricing:latest "$GITHUB_WORKSPACE"
|
||||
|
||||
- name: Redeploy
|
||||
run: |
|
||||
docker rm -f 3d-pricing 2>/dev/null || true
|
||||
docker run -d \
|
||||
--name 3d-pricing \
|
||||
--restart unless-stopped \
|
||||
-p 5010:5000 \
|
||||
-v /opt/3d-pricing-data:/data \
|
||||
-e DATABASE_PATH=/data/pricing.db \
|
||||
3d-pricing:latest
|
||||
|
||||
- name: Healthcheck
|
||||
run: |
|
||||
sleep 5
|
||||
curl -f http://localhost:5010/ || (echo "App not responding!" && exit 1)
|
||||
echo "Redeploy triggered (HTTP $HTTP_CODE)"
|
||||
|
||||
Reference in New Issue
Block a user