在GitHub Action工作流中进行推送或合并之前,如何获取上一次提交?

I'm using Nx for monorepo support on a new project. One of the benefits of Nx is that it can determine which apps in the monorepo are affected by a range of changes (start commit, end commit). So if you have a bunch of apps, you only have to build, test, and deploy the apps that are actually affected by the changes instead of the entire monorepo.

我想设置一个GitHub Action工作流,以便仅在推送或合并到master时部署受影响的应用。但是,我在弄清楚如何获取更改范围的“开始提交”时遇到了麻烦。换句话说,如何获取上次部署的提交哈希?

GitHub provides an env variable GITHUB_SHA but that's the commit that triggered the workflow (i.e. the "end commit"). It also provides GITHUB_BASE_REF but that only works on workflows running from a forked repo comparing to the head repo.

CircleCI has pipeline.git.base_revision for this purpose. Do GitHub Actions have something similar?