This commit is contained in:
@@ -3,6 +3,7 @@ name: Deploy via Portainer
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
@@ -10,9 +11,14 @@ jobs:
|
||||
steps:
|
||||
- name: Trigger Portainer stack redeploy
|
||||
run: |
|
||||
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
|
||||
echo "Redeploy triggered (HTTP $HTTP_CODE)"
|
||||
python3 -c "
|
||||
import urllib.request, sys
|
||||
url = '${{ secrets.PORTAINER_WEBHOOK }}'
|
||||
req = urllib.request.Request(url, method='POST')
|
||||
try:
|
||||
resp = urllib.request.urlopen(req)
|
||||
print('Redeploy triggered (HTTP', resp.status, ')')
|
||||
except urllib.error.HTTPError as e:
|
||||
print('Portainer webhook failed (HTTP', e.code, ')')
|
||||
sys.exit(1)
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user