On pull_request workflow triggers, actions/checkout uses the speculative mere commit of PR head → base branch head instead of the actual PR head itself. I kinda get why that was decided and in some ways, makes things easy and in some ways, hard.
But I wanted to understand how Vercel auto preview build + deploys behave. I was trying to move to a more GitHub Actions-centric workflow to do all builds + deploys (IDK why this is so difficult to do with Vercel) so was trying out manually building + deploying to Vercel from GitHub Actions using vercel CLI. I observed the following:
where right is after creating vercel project, where the initial commit was deployed to prod, where the links + commit info is all correct. But when I did vercel build + vercel deploy from GitHub workflow, I saw weird stuff which can now be explained because of pull_request behavior.
So, are Vercel auto deploys then always picking the head commit of a PR branch and is that why the branch/commit info is correct? If yes, does this mean that we cannot rely on pull_request events at all when working with Vercel GitHub integration since the results would be different for jobs running on Vercel vs GitHub Actions?
I’ve seen others suggest alternatives like pull_request_target event (but be careful with security implications) or push event on feature branches instead of pull_request
Using GitHub Actions instead of Vercel’s automatic deployment workflow would give you more control over which commit gets deployed.
There’s a Vercel project git configuration option that will let you disable the automatic deployments so you can handle it GitHub Actions if that’s what you want to do.
Yeap, we’re leaning strongly towards this now. I can imagine why Vercel’s current approach is unchanged but would be nice to have more GitHub Actions or External CI-first integrations (e.g. custom GH action) to do this.
I’m running vercel deploy --prebuilt since the project is already built in the action. The suggestion to use github.event.pull_request.head.sha helped but I’m still not seeing branch details/branch domain when deployed from within the action (just HEAD):
Do I need to manually set some of the env variables outlined in Framework environment variables for this to work? I’m also not seeing the source files that would otherwise be present in a deployment created using the GitHub app integration.
I haven’t tried the suggestion to just run vercel deploy and let Vercel do the build but what I was hoping to do was to do built within GitHub itself.