mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Meta: Use SerenityBot for IRC notifications
This avoids "useless" join/part notifications.
This commit is contained in:
parent
80d1e12116
commit
ef9ac8a8a2
2 changed files with 17 additions and 24 deletions
21
.github/workflows/cmake.yml
vendored
21
.github/workflows/cmake.yml
vendored
|
@ -77,7 +77,6 @@ jobs:
|
||||||
run: DISABLE_DBG_OUTPUT=1 ./test-js
|
run: DISABLE_DBG_OUTPUT=1 ./test-js
|
||||||
|
|
||||||
# === NOTIFICATIONS ===
|
# === NOTIFICATIONS ===
|
||||||
# https://github.com/rectalogic/notify-irc
|
|
||||||
|
|
||||||
- name: Dump event info
|
- name: Dump event info
|
||||||
if: always()
|
if: always()
|
||||||
|
@ -87,25 +86,11 @@ jobs:
|
||||||
${{ toJSON(github.event) }}
|
${{ toJSON(github.event) }}
|
||||||
EOF
|
EOF
|
||||||
- name: Generate IRC message
|
- name: Generate IRC message
|
||||||
if: always()
|
# I really dislike putting so much logic here, but I can't come up with something better.
|
||||||
id: ircmsg
|
if: github.repository == 'SerenityOS/serenity' && !cancelled() && (github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master'))
|
||||||
run: |
|
run: |
|
||||||
${{ github.workspace }}/Meta/mangle_event_for_irc.py <<"EOF"
|
${{ github.workspace }}/Meta/notify_irc.py <<"EOF"
|
||||||
["${{ github.actor }}", ${{ github.run_id }}, "${{ job.status }}",
|
["${{ github.actor }}", ${{ github.run_id }}, "${{ job.status }}",
|
||||||
${{ toJSON(github.event) }}
|
${{ toJSON(github.event) }}
|
||||||
]
|
]
|
||||||
EOF
|
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 }}
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ TEMPLATE_PUSH = '''\
|
||||||
TEMPLATE_PR = '''\
|
TEMPLATE_PR = '''\
|
||||||
{title} ({actor} {action}: {status}) {link} https://github.com/SerenityOS/serenity/actions/runs/{run_id}\
|
{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):
|
def compute_lines(wrapper):
|
||||||
actor, run_id, raw_status, event = wrapper
|
actor, run_id, raw_status, event = wrapper
|
||||||
|
@ -77,15 +79,21 @@ def compute_lines(wrapper):
|
||||||
return False
|
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):
|
def run_on(json_string):
|
||||||
wrapper = json.loads(json_string)
|
wrapper = json.loads(json_string)
|
||||||
line = compute_lines(wrapper)
|
line = compute_lines(wrapper)
|
||||||
has_output = bool(line)
|
if line:
|
||||||
print('::set-output name=has_output::{}'.format(has_output))
|
send_notification(line)
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
Loading…
Reference in a new issue