Skip to content

Bump js-yaml from 4.1.0 to 4.1.1 in /tools/node in the npm_and_yarn group across 1 directory #2

Bump js-yaml from 4.1.0 to 4.1.1 in /tools/node in the npm_and_yarn group across 1 directory

Bump js-yaml from 4.1.0 to 4.1.1 in /tools/node in the npm_and_yarn group across 1 directory #2

name: PR Comment Handler
on:
issue_comment:
types: [created]
permissions:
contents: write
jobs:
handle-comment:
if: github.event.issue.pull_request
runs-on: ubuntu-latest
steps:
- name: Quick checkout for config
uses: actions/checkout@v4
with:
sparse-checkout: configs/config.yaml
sparse-checkout-cone-mode: false
- name: Check if commenter is excluded bot
id: check_bot
run: |
COMMENTER="${{ github.event.comment.user.login }}"
echo "Checking if '$COMMENTER' is an excluded bot..."
# Check if bot exclusions are enabled
BOT_EXCLUSIONS_ENABLED=$(yq '.comment_analyzer.bot_exclusions.enabled // false' configs/config.yaml)
if [ "$BOT_EXCLUSIONS_ENABLED" != "true" ]; then
echo "Bot exclusions disabled, processing comment"
echo "is_excluded=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check excluded users list
EXCLUDED_USERS=$(yq '.comment_analyzer.bot_exclusions.excluded_users[]' configs/config.yaml 2>/dev/null || echo "")
for user in $EXCLUDED_USERS; do
# Remove quotes from YAML output
user=$(echo "$user" | tr -d '"')
if [ "$COMMENTER" = "$user" ]; then
echo "User '$COMMENTER' is in excluded list, skipping"
echo "is_excluded=true" >> $GITHUB_OUTPUT
exit 0
fi
done
# Check for [bot] suffix if enabled
EXCLUDE_BOT_SUFFIX=$(yq '.comment_analyzer.bot_exclusions.exclude_bot_suffix // false' configs/config.yaml)
if [ "$EXCLUDE_BOT_SUFFIX" = "true" ]; then
if [[ "$COMMENTER" == *"[bot]" ]]; then
echo "User '$COMMENTER' has [bot] suffix, skipping"
echo "is_excluded=true" >> $GITHUB_OUTPUT
exit 0
fi
fi
echo "User '$COMMENTER' is not excluded, processing comment"
echo "is_excluded=false" >> $GITHUB_OUTPUT
- name: Check if comment analysis is enabled
if: steps.check_bot.outputs.is_excluded != 'true'
id: check_config
run: |
ENABLED=$(yq '.comment_analyzer.enabled // false' configs/config.yaml)
echo "result=$ENABLED" >> $GITHUB_OUTPUT
- name: Full checkout
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true'
uses: actions/checkout@v4
# Define reusable condition: not a bot AND analysis enabled
# All subsequent steps use this combined condition
- name: Set up Python
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install Poetry
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true'
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true'
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Python dependencies
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true' && steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry env use python
poetry install --no-interaction --no-root
- name: Create Integration Event
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true'
run: |
PAYLOAD=$(jq -n \
--arg body "${{ github.event.comment.body }}" \
--arg path "${{ github.event.comment.path }}" \
--arg diff_url "${{ github.event.issue.pull_request.diff_url }}" \
'{body: $body, path: $path, diff_url: $diff_url}')
poetry run autopr create-event --event-type "pr_comment" --payload "$PAYLOAD"
- name: Analyze Comment
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true'
id: analysis
run: |
COMMENT_BODY="${{ github.event.comment.body }}"
FILE_PATH="${{ github.event.comment.path }}"
PR_DIFF_URL="${{ github.event.issue.pull_request.diff_url }}"
PR_DIFF=$(curl -sL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_DIFF_URL)
ANALYSIS_JSON=$(poetry run autopr analyze-comment --comment-body "$COMMENT_BODY" --file-path "$FILE_PATH" --pr-diff "$PR_DIFF")
echo "json=$ANALYSIS_JSON" >> $GITHUB_OUTPUT
- name: Apply Fix
if: steps.check_bot.outputs.is_excluded != 'true' && steps.check_config.outputs.result == 'true' && fromJson(steps.analysis.outputs.json).auto_fixable
run: |
FILE_PATH="${{ github.event.comment.path }}"
python scripts/comment_handler.py '${{ steps.analysis.outputs.json }}' "$FILE_PATH"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}