Skip to content

another new file

another new file #9

Workflow file for this run

name: PR Comment Bot
on:
pull_request_target:
types: [opened, edited]
jobs:
update-pr-body:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout code # Checks out the base branch, not PR branch.
uses: actions/checkout@v4
- name: Detect PR type from checkboxes
id: detect-type
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
PR_TYPE=""
# Check for checked boxes (supports [x] and [X])
if echo "$PR_BODY" | grep -qi '\[x\] Bug fix'; then
PR_TYPE="bug"
elif echo "$PR_BODY" | grep -qi '\[x\] Feature'; then
PR_TYPE="feature"
elif echo "$PR_BODY" | grep -qi '\[x\] Documentation'; then
PR_TYPE="documentation"
fi
echo "pr_type=$PR_TYPE" >> "$GITHUB_OUTPUT"
echo "Detected PR type: $PR_TYPE"
- name: Update PR body with checklist
if: steps.detect-type.outputs.pr_type != '' && !contains(github.event.pull_request.body, 'mellea-pr-edited-marker')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BODY: ${{ github.event.pull_request.body }}
PR_TYPE: ${{ steps.detect-type.outputs.pr_type }}
run: |
TEMPLATE_FILE=".github/PULL_REQUEST_TEMPLATE/${PR_TYPE}.md"
if [ -f "$TEMPLATE_FILE" ]; then
TEMPLATE_CONTENT=$(cat "$TEMPLATE_FILE")
gh pr edit ${{ github.event.pull_request.number }} --body "$TEMPLATE_CONTENT"
echo "Updated PR body with ${PR_TYPE} checklist"
else
echo "Template file not found: $TEMPLATE_FILE"
fi
# TODO: JAL. Can include a check that it's the modified PR with the check.
# TODO: JAL. Can update after the fact as well... and fail with some message about nothing selected...
# -> if so, need to trigger on update or something like that...