fix automated PR review workflow for forks (#3867)

This commit is contained in:
Ludovico Magnocavallo
2026-04-14 16:22:20 +02:00
committed by GitHub
parent 9c40f56332
commit 0b5e6cc2ac

View File

@@ -15,7 +15,7 @@
name: "Automated PR Review" name: "Automated PR Review"
# yamllint disable-line rule:truthy # yamllint disable-line rule:truthy
on: on:
pull_request: pull_request_target:
types: types:
- opened - opened
- synchronize - synchronize
@@ -60,12 +60,12 @@ jobs:
- id: generate-diff - id: generate-diff
name: Generate PR Diff name: Generate PR Diff
env: env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
BASE_SHA: ${{ github.event.pull_request.base.sha }} BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: | run: |
# Fetch the target branch to ensure we have the base commit to compare against # Fetch the pull request head
git fetch origin "$BASE_REF":"$BASE_REF" git fetch origin pull/$PR_NUMBER/head
# Generate the diff between the PR base and the PR head # Generate the diff between the PR base and the PR head
git diff "$BASE_SHA"..."$HEAD_SHA" > pr.diff git diff "$BASE_SHA"..."$HEAD_SHA" > pr.diff