@@ -1838,14 +1838,18 @@ const run = async () => {
18381838 // not the *latest commit* of the PR which is what Netlify uses. Instead,
18391839 // have to use github.context.payload.pull_request.head.sha
18401840 // See: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request
1841- const commitSha = github.context.payload.pull_request.head.sha;
1841+ const isPr = 'pull_request' in github.context.payload;
1842+ const commitSha = isPr ? github.context.payload.pull_request.head.sha : github.context.sha;
18421843 const MAX_TIMEOUT = Number(core.getInput('max_timeout')) || 60;
18431844 const siteName = core.getInput('site_name');
18441845 if (!netlifyToken) {
18451846 core.setFailed('Please set NETLIFY_TOKEN env variable to your Netlify Personal Access Token secret');
18461847 }
1848+
18471849 if (!commitSha) {
18481850 core.setFailed('Could not determine GitHub commit');
1851+ } else {
1852+ console.log('Using SHA', commitSha, isPr ? 'from PR' : '');
18491853 }
18501854 if (!siteName) {
18511855 core.setFailed('Required field `site_name` was not provided');
@@ -1867,7 +1871,7 @@ const run = async () => {
18671871 // Most likely, it's the first entry in the response
18681872 // but we correlate it just to be safe
18691873 const commitDeployment = netlifyDeployments.find(
1870- (d) => d.commit_ref === commitSha && d.context === 'deploy-preview',
1874+ (d) => d.commit_ref === commitSha && d.context === (isPr ? 'deploy-preview' : 'production') ,
18711875 );
18721876 if (!commitDeployment) {
18731877 core.setFailed(`Could not find deployment for commit ${commitSha}`);
0 commit comments