Skip to content

Commit 51bb91e

Browse files
committed
ci: refactor conditional parts
1 parent 6b23cb7 commit 51bb91e

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

.github/workflows/send-emails.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,8 @@ jobs:
7474
7575
echo "SERIES_DIR=/tmp/series" >> $GITHUB_ENV
7676
77-
- name: Check for label 'no-ml' to skip sending emails
78-
id: checklabel
79-
run: |
80-
# Skip if PR has label "no-ml"
81-
if echo "$PR_LABELS" | grep -qiE "(^|,)no-ml(,|$)"; then
82-
echo "Opt-out label present: skipping mailing list." | tee $GITHUB_STEP_SUMMARY
83-
echo "skip_sending=1" >> $GITHUB_OUTPUT
84-
else
85-
echo "skip_sending=0" >> $GITHUB_OUTPUT
86-
fi
87-
8877
- name: Get commit list from PR and skip the internal ones
8978
id: commits
90-
if: ${{ steps.checklabel.outputs.skip_sending != '1' }}
9179
run: |
9280
# Skip commits that touches any of these
9381
patterns=(".github/"
@@ -120,20 +108,46 @@ jobs:
120108
echo "has_commits=false" >> $GITHUB_OUTPUT
121109
else
122110
COUNT=$(wc -l < /tmp/commits.txt)
111+
echo "Adding one commit to the send list"
123112
echo "COUNT=$COUNT" >> $GITHUB_ENV
124113
echo "has_commits=true" >> $GITHUB_OUTPUT
125114
fi
126115
127116
- name: Check what to do based on series' size
128117
if: steps.commits.outputs.has_commits == 'true'
118+
id: count_commits
129119
run: |
130120
MAX=150
131121
if [ "${COUNT}" -gt "$MAX" ]; then
132122
echo "Series has $COUNT commits (> $MAX). Not doing anything" | tee $GITHUB_STEP_SUMMARY
123+
echo skip=true >> $GITHUB_OUTPUT
124+
else
125+
echo "Will send the series"
126+
echo skip=false >> $GITHUB_OUTPUT
133127
fi
134128
129+
- name: Check for label 'no-ml' to skip sending emails
130+
id: checklabel
131+
run: |
132+
# Skip if PR has label "no-ml"
133+
if echo "$PR_LABELS" | grep -qiE "(^|,)no-ml(,|$)"; then
134+
echo "Opt-out label present: skipping mailing list." | tee $GITHUB_STEP_SUMMARY
135+
echo "skip=true" >> $GITHUB_OUTPUT
136+
else
137+
echo "No opt-out label found"
138+
echo "skip=false" >> $GITHUB_OUTPUT
139+
fi
140+
141+
- name: Decide if we're sending something or not
142+
id: send_emails
143+
if: ( steps.commits.outputs.has_commits == 'true' &&
144+
steps.count_commits.outputs.skip == 'false' &&
145+
steps.checklabel.outputs.skip == 'false' )
146+
run: |
147+
echo "enabled=true" >> $GITHUB_OUTPUT
148+
135149
- name: Prepare patch series
136-
if: steps.commits.outputs.has_commits == 'true'
150+
if: steps.send_emails.outputs.enabled == 'true'
137151
run: |
138152
set -euo pipefail
139153
@@ -190,7 +204,7 @@ jobs:
190204
done < <(find /tmp/series/ -maxdepth 1 -type f -print0|sort -z -n)
191205
192206
- name: Send series via git send-email
193-
if: steps.commits.outputs.has_commits == 'true'
207+
if: steps.send_emails.outputs.enabled == 'true'
194208
env:
195209
GIT_SMTP_SERVER: ${{ secrets.SMTP_SERVER }}
196210
GIT_SMTP_ENCRYPTION: tls

0 commit comments

Comments
 (0)