Skip to content

Commit d73c474

Browse files
committed
Improve changelog check error handling
1 parent e9728b8 commit d73c474

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/clippy_bors.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ jobs:
3434
run: |
3535
MESSAGE=$(git log --format=%B -n 1)
3636
PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
37-
output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
38-
python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
39-
grep "^changelog: " | \
40-
sed "s/changelog: //g")
37+
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
38+
python -c "import sys, json; print(json.load(sys.stdin)['body'])")
39+
output=$(grep "^changelog: " <<< "$body" | sed "s/changelog: //g") || {
40+
echo 'ERROR: Could not find "changelog: ..." in the PR body' >&2
41+
exit 1
42+
}
4143
if [[ -z "$output" ]]; then
42-
echo "ERROR: PR body must contain 'changelog: ...'"
44+
echo "ERROR: PR body must contain 'changelog: ...'" >&2
4345
exit 1
4446
elif [[ "$output" = "none" ]]; then
4547
echo "WARNING: changelog is 'none'"
48+
else
49+
echo "changelog: $output"
4650
fi
4751
env:
4852
PYTHONIOENCODING: 'utf-8'

0 commit comments

Comments
 (0)