diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index 768325f9f5..89e1e69c60 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -16,13 +16,17 @@ jobs: shell: bash run: | set -ex - # Checkout a detached head, and then fetch the base ref to populate the detached head. - git checkout "${base_ref}" - git fetch --no-tags --prune origin +${base_ref}:refs/remotes/origin/${base_ref} - # Checkout a detached head, and then fetch the head ref to populate the detached head. - git checkout "${head_ref}" - git fetch --no-tags --prune origin +${head_ref}:refs/remotes/origin/${head_ref} - changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" + # PRs that come from a fork need to be handled differently + if [[ ${head_repo_name} == ${base_repo} ]]; then + git checkout ${base_ref} + git checkout ${head_ref} + changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" + else + git remote add fork ${head_repo_url} + git fetch fork # create a mapping of the fork + git checkout -b "${head_ref}" fork/${head_ref} + changed_directories="$(git diff --name-only "fork/${head_ref}" "origin/${base_ref}")" + fi if [[ ${changed_directories} =~ "library_generation/" ]]; then echo "should_run=true" >> $GITHUB_OUTPUT else @@ -31,6 +35,9 @@ jobs: env: base_ref: ${{ github.event.pull_request.base.ref }} head_ref: ${{ github.event.pull_request.head.ref }} + head_repo_url: ${{ github.event.pull_request.head.repo.html_url }} + head_repo_name: ${{ github.event.pull_request.head.repo.full_name }} + base_repo: ${{ github.repository }} library-generation-integration-tests: runs-on: ubuntu-22.04 needs: should-run-library-generation-tests