Bugfix: Add Portainer deployment trigger to CI workflow
- Introduced a new step in the CI workflow to trigger a Portainer deployment using a webhook. - Added checks for the presence of the PORTAINER_WEBHOOK_URL secret and handled HTTP response codes from the webhook call. - Ensured that the workflow does not fail if the webhook call is unsuccessful. This enhancement streamlines the deployment process by automating updates to the Portainer stack upon successful CI runs.
This commit is contained in:
parent
186fb03ab8
commit
26bb17c901
1 changed files with 32 additions and 0 deletions
|
|
@ -297,6 +297,38 @@ jobs:
|
||||||
echo "✅ Successfully committed and pushed version update to $VERSION"
|
echo "✅ Successfully committed and pushed version update to $VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Trigger Portainer Deployment
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
WEBHOOK_URL="${{ secrets.PORTAINER_WEBHOOK_URL }}"
|
||||||
|
|
||||||
|
if [[ -z "$WEBHOOK_URL" ]]; then
|
||||||
|
echo "⚠️ Warning: PORTAINER_WEBHOOK_URL secret not set, skipping webhook call"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🚀 Triggering Portainer deployment for version $VERSION"
|
||||||
|
|
||||||
|
# Call Portainer webhook to trigger stack update
|
||||||
|
HTTP_CODE=$(curl -s -o /tmp/webhook_response.txt -w "%{http_code}" -X POST "$WEBHOOK_URL" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--max-time 30)
|
||||||
|
|
||||||
|
if [[ "$HTTP_CODE" -ge 200 && "$HTTP_CODE" -lt 300 ]]; then
|
||||||
|
echo "✅ Successfully triggered Portainer deployment (HTTP $HTTP_CODE)"
|
||||||
|
if [[ -f /tmp/webhook_response.txt ]]; then
|
||||||
|
echo "Response: $(cat /tmp/webhook_response.txt)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ Warning: Webhook call returned HTTP $HTTP_CODE"
|
||||||
|
if [[ -f /tmp/webhook_response.txt ]]; then
|
||||||
|
echo "Response: $(cat /tmp/webhook_response.txt)"
|
||||||
|
fi
|
||||||
|
# Don't fail the workflow if webhook fails
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Job Summary
|
- name: Job Summary
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue