diff --git a/.github/workflows/pkgcheck-comment.yml b/.github/workflows/pkgcheck-comment.yml index 02823130c47..b51655a3d7e 100644 --- a/.github/workflows/pkgcheck-comment.yml +++ b/.github/workflows/pkgcheck-comment.yml @@ -44,7 +44,7 @@ jobs: RUN_URL: ${{ github.event.workflow_run.html_url }} run: scripts/pkgcheck-comment.sh pkgcheck-report - - name: close a pull request with malformed commits + - name: close a pull request that breaks the pull request rules env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} HEAD_SHA: ${{ github.event.workflow_run.head_sha }} @@ -53,9 +53,15 @@ jobs: pr=$(jq -r --arg sha "$HEAD_SHA" 'first(.[][] | select(.head.sha == $sha) | .number) // empty' <<< "$pulls") [ -n "$pr" ] || exit 0 bad=$(scripts/commit-rules.sh "$pr") - [ -n "$bad" ] || exit 0 - cat > body.md < body.md + if [ -n "$bad" ]; then + cat >> body.md <> body.md <> body.md < +# prints the checkboxes of .github/pull_request_template.md missing from the pull request description +set -euo pipefail +pr=$(gh api "repos/$GITHUB_REPOSITORY/pulls/${1:?pull request number}") +[ "$(jq -r .user.login <<< "$pr")" != 'gentoo-zh-autobump[bot]' ] || exit 0 +body=$(jq -r '.body // ""' <<< "$pr") +# shellcheck disable=SC2016 # literal backticks of the template +for box in 'I have run `pkgcheck scan --commits --net`' 'If I used AI:'; do + grep -iF -- "$box" <<< "$body" | grep -qE '^- \[[ xX]\] ' || echo "- $box" +done