Deploy per Portainer-Webhook statt Polling
CI / test (push) Successful in 4m7s
CI / build-and-push (push) Successful in 5m40s
CI / deploy (push) Successful in 6s

Nach erfolgreichem Push in findr/infrastructure den Stack-Webhook
aufrufen (PORTAINER_WEBHOOK-Secret), damit der Redeploy sofort
statt auf einen Timer passiert.

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2026-09-04 10:50:06 +02:00
parent 3fc0c82012
commit ec7a6d57cb
+19 -13
View File
@@ -104,16 +104,12 @@ jobs:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: docker push "$IMAGE:latest"
# The stack lives in the infrastructure repo and Portainer deploys it from
# there, so a rollout is a commit in that repo: it pins the findr-api image to
# this build's commit. Compose then recreates the one service whose image
# changed. Leaving the stack on ":latest" and only re-pulling would drag
# findr-web and postgres along with every api deploy, and nothing in Git would
# say which version is running.
#
# Pushing the commit is the whole job - Portainer polls the repo and redeploys
# once it sees a new head. A green job therefore means the rollout was handed
# over, not that it has happened yet.
# The stack lives in the infrastructure repo, so a rollout is a commit in that
# repo: it pins the findr-api image to this build's commit. Then the Portainer
# stack webhook is called, which re-pulls the repo and recreates the one
# service whose image changed. Leaving the stack on ":latest" and only
# re-pulling would drag findr-web and postgres along with every api deploy, and
# nothing in Git would say which version is running.
deploy:
runs-on: ubuntu-latest
timeout-minutes: 10
@@ -122,9 +118,10 @@ jobs:
steps:
# The token goes into the remote URL, so it must not be echoed - it can
# write to the whole infrastructure repo. No "set -x" here either.
- name: Pin findr-api image in the stack
- name: Pin findr-api image and trigger the stack
env:
INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }}
PORTAINER_WEBHOOK: ${{ secrets.PORTAINER_WEBHOOK }}
TAG: ${{ needs.build-and-push.outputs.tag }}
run: |
set -euo pipefail
@@ -160,8 +157,17 @@ jobs:
# findr-web writes to the same file, so a push can lose a race.
# Rebasing and retrying beats failing a build whose image is already in
# the registry.
pushed=
for attempt in 1 2 3; do
git push && exit 0
if git push; then pushed=1; break; fi
git pull --rebase
done
exit 1
[ -n "$pushed" ] || exit 1
# No polling: tell Portainer to redeploy now. -k because :9443 serves a
# self-signed cert. The URL carries a secret, so it comes from a secret
# and is never printed.
if [ -z "${PORTAINER_WEBHOOK:-}" ]; then
echo "::error::PORTAINER_WEBHOOK secret is not set" && exit 1
fi
curl -fsS -k -X POST "$PORTAINER_WEBHOOK"