Awoeifjawef #26
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Comment Bot | |
| on: | |
| pull_request_target: | |
| types: [opened, edited] | |
| jobs: | |
| update-pr-body: | |
| runs-on: ubuntu-latest | |
| if: ${{ !contains(github.event.pull_request.body, 'mellea-pr-edited-marker') }} | |
| 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 | |
| if [ -z "$PR_TYPE" ]; then | |
| echo "::error::No PR type selected. Please check one of: Bug fix, Feature, or Documentation." | |
| exit 1 | |
| fi | |
| echo "pr_type=$PR_TYPE" >> "$GITHUB_OUTPUT" | |
| echo "Detected PR type: $PR_TYPE" | |
| - name: Update PR body with checklist | |
| 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 | |
| MARKER="<!-- mellea-pr-edited-marker: do not remove this marker -->" | |
| TEMPLATE_CONTENT=$(cat "$TEMPLATE_FILE") | |
| NEW_BODY="${MARKER} | |
| ${TEMPLATE_CONTENT}" | |
| gh pr edit ${{ github.event.pull_request.number }} --body "$NEW_BODY" | |
| echo "Updated PR body with ${PR_TYPE} checklist" | |
| else | |
| echo "Template file not found: $TEMPLATE_FILE" | |
| fi |