feat(deploy): gitea webhook - pull + minimal reload pipeline [#734]
Webhook automation: master pushes force a git pull then reload_all; core restart only for configuration.yaml / packages platform files. Add-on auto_restart disabled separately on the host (race source). Detail: https://projects.knownelement.com/issues/734
This commit is contained in:
@@ -225,3 +225,70 @@
|
|||||||
message: '{{ trigger.entity_id }} climbing ~10F/15min — check cooling
|
message: '{{ trigger.entity_id }} climbing ~10F/15min — check cooling
|
||||||
before the 104F threshold. (rate-of-change early warning)'
|
before the 104F threshold. (rate-of-change early warning)'
|
||||||
mode: single
|
mode: single
|
||||||
|
# Deploy pipeline [#734]: gitea repo webhook (master pushes) -> forced pull
|
||||||
|
# -> minimal reload. Core restarts ONLY when configuration.yaml or a
|
||||||
|
# packages platform-sensor file changed; everything else reloads with no
|
||||||
|
# bounce. The git_pull add-on's auto_restart is disabled - this webhook
|
||||||
|
# owns apply timing (no more 5-min-timer surprise restarts).
|
||||||
|
- id: pfv_deploy_git_webhook
|
||||||
|
alias: PFV deploy - git push to pull + minimal reload
|
||||||
|
description: >-
|
||||||
|
Gitea webhook on master pushes. Forces a git pull now, then
|
||||||
|
homeassistant.reload_all unless files that require a core restart
|
||||||
|
changed. Replaces the git_pull add-on timer auto-restart [#734].
|
||||||
|
mode: queued
|
||||||
|
max_exceeded: silent
|
||||||
|
triggers:
|
||||||
|
- trigger: webhook
|
||||||
|
webhook_id: !secret deploy_webhook_id
|
||||||
|
allowed_methods:
|
||||||
|
- POST
|
||||||
|
local_only: false
|
||||||
|
conditions: []
|
||||||
|
actions:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.json.ref | default('') != 'refs/heads/master' }}"
|
||||||
|
then:
|
||||||
|
- stop: non-master ref ignored
|
||||||
|
stop_reason: "deploy webhook: non-master ref {{ trigger.json.ref | default('') }}"
|
||||||
|
- variables:
|
||||||
|
changed_files: >-
|
||||||
|
{{ (trigger.json.commits | default([]) | map(attribute='added') | flatten | list)
|
||||||
|
+ (trigger.json.commits | default([]) | map(attribute='removed') | flatten | list)
|
||||||
|
+ (trigger.json.commits | default([]) | map(attribute='modified') | flatten | list) }}
|
||||||
|
need_restart: >-
|
||||||
|
{{ changed_files | select('in', ['configuration.yaml', 'packages/plant_snmp.yaml']) | list | count > 0 }}
|
||||||
|
- action: persistent_notification.create
|
||||||
|
data:
|
||||||
|
title: Deploy started
|
||||||
|
message: >-
|
||||||
|
Git push ({{ trigger.json.sender.login | default('unknown') }}):
|
||||||
|
{{ trigger.json.commits | default([]) | map(attribute='message') | join(' | ') | truncate(160) }}.
|
||||||
|
Pulling now - {{ 'core restart required' if need_restart else 'reload only, no restart' }}.
|
||||||
|
- action: hassio.addon_restart
|
||||||
|
data:
|
||||||
|
addon: core_git_pull
|
||||||
|
- delay:
|
||||||
|
hours: 0
|
||||||
|
minutes: 0
|
||||||
|
seconds: 25
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ need_restart }}"
|
||||||
|
then:
|
||||||
|
- action: persistent_notification.create
|
||||||
|
data:
|
||||||
|
title: Deploy - restarting core
|
||||||
|
message: "Pull done; restarting core for {{ changed_files | join(', ') }}. Back in ~1 min."
|
||||||
|
- delay:
|
||||||
|
hours: 0
|
||||||
|
minutes: 0
|
||||||
|
seconds: 3
|
||||||
|
- action: homeassistant.restart
|
||||||
|
else:
|
||||||
|
- action: homeassistant.reload_all
|
||||||
|
- action: persistent_notification.create
|
||||||
|
data:
|
||||||
|
title: Deploy complete
|
||||||
|
message: "Pulled + reloaded YAML config at {{ now().strftime('%H:%M:%S') }} (no core restart). Files: {{ changed_files | join(', ') | truncate(200) }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user