Pull Request from fork has different files in GitHub action

When having a Pull Request from a fork that is based on an older master branch from the target repository, then a merge with the HEAD of the Pull Request source branch and HEAD of the target branch. At least it looks like it from the git log -1: Add git log · screego/server@f331a14 · GitHub

commit eb0e3a5709f9b97bcbca58f59ffe45c6ffa1173b
Author: XX XX
Date:   Sun Aug 22 17:51:39 2021 +0000

    Merge f331a1427be373bda94facb9eed4c7e5dd071449 into aeb55c7387f27de252aefbee0b45f23d7e0ff645

aeb55c7387f27de252aefbee0b45f23d7e0ff645 is the current commit from the target master branch.
f331a1427be373bda94facb9eed4c7e5dd071449 was the commit from the branch on the fork.

This messes up some files in an unexpected way. In my case, it installs different versions of dependencies in the GitHub Action then when using the branch locally.

Locally, my yarn.lock contains these lines:

$ git log -1
commit f331a1427be373bda94facb9eed4c7e5dd071449 (HEAD -> SvenKube/master)
Author: Jannis Mattheis <contact@jmattheis.de>
Date:   Sun Aug 22 19:51:24 2021 +0200

    Add git log
$ cat ui/yarn.lock| grep prettier
"@types/prettier@^2.0.0":
  resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0"
    "@types/prettier" "^2.0.0"
prettier@^2.2.1:
  resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"

And when executing the same command in a Pull Request GitHub Action from the fork, it contains these lines: Add git log · screego/server@f331a14 · GitHub

Run cat ui/yarn.lock | grep prettier
"@types/prettier@^2.0.0":
  resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0"
    "@types/prettier" "^2.0.0"
prettier@^2.3.1:
  resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.1.tgz#76903c3f8c4449bc9ac597acefa24dc5ad4cbea6"

As you can see, the prettier version changes from 2.2.1 to 2.3.1 and lets the build fail.

If I push the branch from the fork to my repository, it all works, because no merge will be done. I think this is a bug, as builds shouldn’t have different files in a GitHub action.

Pull Request: Add selectable video display mode by SvenKube · Pull Request #90 · screego/server · GitHub
Couldn’t add this to the post because of the link limit for new users.

That is expected behavior: The GITHUB_REF of the pull_request event is a merge commit, basically what you’d get from merging the PR. Theoretically you could get the last commit of the source branch from the event object and check that out instead, but usually testing what would be the result of the merge is a good idea. :slightly_smiling_face: