Skip to content

Commit

Permalink
redo github webhooks automation
Browse files Browse the repository at this point in the history
ref #18
  • Loading branch information
pinkywafer committed Jul 30, 2020
1 parent c44eae0 commit 4f89554
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
50 changes: 22 additions & 28 deletions packages/github/github_webhook.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
automation:
- id: '724c3e88-97c6-4193-b06f-ce468c411e92'
alias: Test github webhook
mode: queued
trigger:
platform: webhook
webhook_id: !secret github_webhook
condition:
- condition: template
value_template: >-
{%- if trigger.json.action == "created" or "closed" or "opened" or "reopened" or trigger.json.ref %}
True
{%- else -%}
False
{%- endif -%}
action:
- service: notify.discord_bot
data_template:
target: !secret discord_ha_instance_id
message: >-
{%- if trigger.json.action == "created" or "closed" or "opened" or "reopened" or trigger.json.ref %}
{%- if trigger.json.pull_request -%}
Pull request {% if trigger.json.comment %} comment {% endif -%}
{{trigger.json.action}}: #{{ trigger.json.pull_request.number}} {{ trigger.json.pull_request.title }}
{{trigger.json.pull_request.html_url}}
{%- elif trigger.json.issue -%}
Issue {% if trigger.json.comment %} comment {% endif -%}
{{trigger.json.action}}: #{{ trigger.json.issue.number}} {{ trigger.json.issue.title }}
{{trigger.json.issue.html_url}}
{%- elif ref %}
{{trigger.json.pusher.name}} pushed {{ trigger.json.commits | count }} commits pushed to Home-Assistant_config
https
{%- endif %}
{% endif %}
# - choose:
# - conditions:
# - condition: template
# entity_id: binary_sensor.button1
# state: "on"
# sequence:
# - service: light.turn_on
# entity_id: light.bulb
# - conditions:


input_text:
test_github_webhook:
initial: "test"
{%- if trigger.json.pull_request -%}
Pull request {% if trigger.json.comment %} comment {% endif -%}
{{trigger.json.action}}: #{{ trigger.json.pull_request.number}} {{ trigger.json.pull_request.title }}
{{trigger.json.pull_request.html_url}}
{%- elif trigger.json.issue -%}
Issue {% if trigger.json.comment %} comment {% endif -%}
{{trigger.json.action}}: #{{ trigger.json.issue.number}} {{ trigger.json.issue.title }}
{{trigger.json.issue.html_url}}
{%- elif ref %}
{{ trigger.json.commits | count }} commits pushed to Home-Assistant_config
https://github.com/pinkywafer/Home-Assistant_Config/commits/master
{%- endif %}
4 changes: 3 additions & 1 deletion travis_secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@ uk_transport_origin: aaaaaaaaaaaaa
spotify_client_id: aaaaaaaaaaaaaaa
spotify_client_secret: aaaaaaaaaaaaaaaaa

github_webhook: aaaaaaaaaaaaaaaaaa
github_webhook: aaaaaaaaaaaaaaaaaa

discord_ha_instance_id: aaaaaaaaaaaaaaaaaa

0 comments on commit 4f89554

Please sign in to comment.