summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-11-14 15:05:29 +0100
committerAndreas Kling <kling@serenityos.org>2020-11-14 15:30:29 +0100
commitef9ac8a8a2a165dc16e6efad460e1fa347c9656f (patch)
tree6d435c5439f32e80e93d411afb2ef3130909ca9b
parent80d1e12116b828616fa710f9ea110154b9bf3970 (diff)
downloadserenity-ef9ac8a8a2a165dc16e6efad460e1fa347c9656f.zip
Meta: Use SerenityBot for IRC notifications
This avoids "useless" join/part notifications.
-rw-r--r--.github/workflows/cmake.yml21
-rwxr-xr-xMeta/notify_irc.py (renamed from Meta/mangle_event_for_irc.py)20
2 files changed, 17 insertions, 24 deletions
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 3b2c0b5801..f3af9ad0c3 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -77,7 +77,6 @@ jobs:
run: DISABLE_DBG_OUTPUT=1 ./test-js
# === NOTIFICATIONS ===
- # https://github.com/rectalogic/notify-irc
- name: Dump event info
if: always()
@@ -87,25 +86,11 @@ jobs:
${{ toJSON(github.event) }}
EOF
- name: Generate IRC message
- if: always()
- id: ircmsg
+ # I really dislike putting so much logic here, but I can't come up with something better.
+ if: github.repository == 'SerenityOS/serenity' && !cancelled() && (github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master'))
run: |
- ${{ github.workspace }}/Meta/mangle_event_for_irc.py <<"EOF"
+ ${{ github.workspace }}/Meta/notify_irc.py <<"EOF"
["${{ github.actor }}", ${{ github.run_id }}, "${{ job.status }}",
${{ toJSON(github.event) }}
]
EOF
- - name: IRC result notification (direct push)
- uses: rectalogic/notify-irc@v1
- if: github.repository == 'SerenityOS/serenity' && github.ref == 'refs/heads/master' && github.event_name == 'push' && !cancelled() && steps.ircmsg.outputs.has_output == 'True'
- with:
- channel: "#serenityos"
- nickname: serenity-ga
- message: ${{ steps.ircmsg.outputs.the_line }}
- - name: IRC result notification (PR)
- uses: rectalogic/notify-irc@v1
- if: github.repository == 'SerenityOS/serenity' && github.event_name == 'pull_request' && !cancelled() && steps.ircmsg.outputs.has_output
- with:
- channel: "#serenityos"
- nickname: serenity-ga
- message: ${{ steps.ircmsg.outputs.the_line }}
diff --git a/Meta/mangle_event_for_irc.py b/Meta/notify_irc.py
index 517c6765d2..1711f57283 100755
--- a/Meta/mangle_event_for_irc.py
+++ b/Meta/notify_irc.py
@@ -11,6 +11,8 @@ TEMPLATE_PUSH = '''\
TEMPLATE_PR = '''\
{title} ({actor} {action}: {status}) {link} https://github.com/SerenityOS/serenity/actions/runs/{run_id}\
'''
+SERENITY_BOT = 'http://94.130.182.143:8080'
+
def compute_lines(wrapper):
actor, run_id, raw_status, event = wrapper
@@ -77,15 +79,21 @@ def compute_lines(wrapper):
return False
+def send_notification(line):
+ print('> ' + line)
+ try:
+ response = requests.post(SERENITY_BOT, data={'msg': line})
+ except BaseException as e:
+ print('Notification failed: {}: {}'.format(type(e), e))
+ else:
+ print('Notification result: HTTP {}'.format(response.status_code))
+
+
def run_on(json_string):
wrapper = json.loads(json_string)
line = compute_lines(wrapper)
- has_output = bool(line)
- print('::set-output name=has_output::{}'.format(has_output))
- print('> ::set-output name=has_output::{}'.format(has_output))
- if has_output:
- print('::set-output name=the_line::{}'.format(line))
- print('> ::set-output name=the_line::{}'.format(line))
+ if line:
+ send_notification(line)
def run():