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.
I'd like to setup a GitHub Action workflow to deploy only the affected apps on push or merge to master. However, I'm having trouble figuring out how to get the "start commit" for the range of changes. In other words, how do I get the commit hash of the last deploy?
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?