Skip to content

Commit 503baeb

Browse files
committed
Read PR body from event in clippy_changelog action
1 parent 689e62b commit 503baeb

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

.github/workflows/clippy_changelog.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,18 @@ jobs:
1515
changelog:
1616
runs-on: ubuntu-latest
1717

18-
defaults:
19-
run:
20-
shell: bash
21-
2218
steps:
2319
# Run
2420
- name: Check Changelog
2521
if: ${{ github.event_name == 'pull_request' }}
2622
run: |
27-
body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | \
28-
python -c "import sys, json; print(json.load(sys.stdin)['body'])")
29-
output=$(awk '/^changelog:\s*\S/ && !/changelog: \[.*\]: your change/' <<< "$body" | sed "s/changelog:\s*//g")
30-
if [ -z "$output" ]; then
31-
echo "ERROR: pull request message must contain 'changelog: ...' with your changelog. Please add it."
23+
if [[ -z $(grep -oP 'changelog: *\K\S+' <<< "$PR_BODY") ]]; then
24+
echo '::error::Pull request message must contain 'changelog: ...' with your changelog. Please add it."
3225
exit 1
33-
else
34-
echo "changelog: $output"
3526
fi
3627
env:
37-
PYTHONIOENCODING: 'utf-8'
38-
PR_NUMBER: '${{ github.event.number }}'
28+
PR_BODY: ${{ github.event.pull_request.body }})
29+
3930

4031
# We need to have the "conclusion" job also on PR CI, to make it possible
4132
# to add PRs to a merge queue.

0 commit comments

Comments
 (0)