forked from Perl/perl5
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (118 loc) · 4.51 KB
/
irc-notifications.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: "Push Notification"
on: [push, pull_request]
# add create for tracking tags
# IRC colors: https://modern.ircdocs.horse/formatting.html
# yaml formating: https://www.yaml.info/learn/quote.html
jobs:
notify-irc:
runs-on: ubuntu-latest
# only on main repo
if: ( github.event.pull_request.head.repo.full_name == 'Perl/perl5' || github.repository == 'Perl/perl5' )
env:
server: ssl.irc.perl.org
port: 7062
channel: "#p5p-commits"
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: setup branch env name
run: |
ref="${github_ref/refs\/heads\//}"
echo "ref=$ref" >> $GITHUB_ENV
env:
github_ref: ${{ github.event.ref }}
- name: Setup commit message SUMUP env
env:
TXT: ${{ join(github.event.commits.*.message, '\n') }}
C1: ${{ github.event.commits[0].message }}
C2: ${{ github.event.commits[1].message }}
C3: ${{ github.event.commits[2].message }}
C4: ${{ github.event.commits[3].message }}
C5: ${{ github.event.commits[4].message }}
run: |
# -------------------------------------
echo "# original commit message"
echo "TXT=$TXT"
# -------------------------------------
echo "# Last 5 commits message"
echo "C1=$C1"
echo "C2=$C2"
echo "C3=$C3"
echo "C4=$C4"
echo "C5=$C5"
# -------------------------------------
echo "# script parse.pl"
cat <<'EOS' > parse.pl
use v5.14; use strict; use warnings;
my $txt = join "\n", map { $ENV{"C$_"} // '' } 1..5;
$txt =~ s{\\n}{\n}g; $txt =~ s{\\t}{ }g; $txt =~ s{\t}{ }g;
my @l = split( "\n", $txt );
my $max = 5;
@l = ( @l[0..$max], "..." ) if @l > $max;
@l = grep { $_ !~ m{^EOF} } @l;
say( join( "\n", @l ) );
EOS
# -------------------------------------
echo "# testing script"
perl parse.pl
# -------------------------------------
echo "# setup SUMUP environment variable"
echo 'SUMUP<<EOF' >> $GITHUB_ENV
perl parse.pl >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# -------------------------------------
echo "# done"
- name: checking SUMUP variable
run: |
echo "SUMUP: $SUMUP"
- name: irc push
uses: rectalogic/notify-irc@v1
if: github.event_name == 'push' && github.ref != 'refs/heads/blead'
with:
server: ${{ env.server }}
port: ${{ env.port }}
channel: ${{ env.channel }}
nickname: Commit
message:
"\x037${{ github.actor }}\x0F pushed to branch \x033${{ env.ref }}\x0F\n\
${{ env.SUMUP }}\n\
${{ github.event.compare }}"
- name: irc push to blead
uses: rectalogic/notify-irc@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/blead'
with:
server: ${{ env.server }}
port: ${{ env.port }}
channel: ${{ env.channel }}
nickname: inBlead
message:
"\x0313[blead]\x0F \x037${{ github.actor }}\x0F pushed to blead\n\
${{ env.SUMUP }}\n\
${{ github.event.compare }}"
- name: irc opened pull request
uses: rectalogic/notify-irc@v1
if: github.event_name == 'pull_request' && github.event.action == 'opened'
with:
server: ${{ env.server }}
port: ${{ env.port }}
channel: ${{ env.channel }}
nickname: Pull-Request
message:
"\x037${{ github.actor }}\x0F opened PR #${{ github.event.pull_request.number }}\n\
${{ github.event.pull_request.title }}\n\
${{ github.event.pull_request.body }}\n\
${{ github.event.pull_request.html_url }}"
- name: irc synchronize pull request
uses: rectalogic/notify-irc@v1
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
with:
server: ${{ env.server }}
port: ${{ env.port }}
channel: ${{ env.channel }}
nickname: Pull-Request
message:
"\x037${{ github.actor }}\x0F updated PR #${{ github.event.pull_request.number }}\n\
${{ github.event.pull_request.title }}\n\
${{ github.event.pull_request.html_url }}"