Skip to content

Commit 9297bc9

Browse files
committed
fix: typo affecting commit and compareSHA
i also added checks for the merge group event just in case
1 parent 0ac5be0 commit 9297bc9

File tree

4 files changed

+646
-3382
lines changed

4 files changed

+646
-3382
lines changed

packages/bundler-plugin-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"zod": "^3.22.4"
4848
},
4949
"devDependencies": {
50-
"@octokit/webhooks-definitions": "^3.67.3",
50+
"@octokit/webhooks-types": "^7.6.1",
5151
"@sentry/core": "^8.42.0",
5252
"@types/node": "^20.11.15",
5353
"@types/semver": "^7.5.6",

packages/bundler-plugin-core/src/utils/providers/GitHubActions.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
} from "../../types.ts";
88
import { type Output } from "../Output.ts";
99
import { debug } from "../logging.ts";
10-
import { type PullRequestEvent } from "@octokit/webhooks-definitions/schema";
10+
import {
11+
type PullRequestEvent,
12+
type MergeGroupEvent,
13+
} from "@octokit/webhooks-types";
1114

1215
export function detect(envs: ProviderEnvs): boolean {
1316
return Boolean(envs?.GITHUB_ACTIONS);
@@ -42,7 +45,7 @@ async function _getJobURL(
4245
});
4346

4447
if (res.status !== 200) {
45-
debug(`Failed to get job URL: ${res.status}`, { enabled: output.debug });
48+
debug(`Failed to get job U1RL: ${res.status}`, { enabled: output.debug });
4649
return null;
4750
}
4851

@@ -184,9 +187,12 @@ function _getSHA(
184187

185188
const context = GitHub.context;
186189
let commit = envs?.GITHUB_SHA;
187-
if (["pull_request", " pull_request_target"].includes(context.eventName)) {
190+
if (["pull_request", "pull_request_target"].includes(context.eventName)) {
188191
const payload = context.payload as PullRequestEvent;
189192
commit = payload.pull_request.head.sha;
193+
} else if ("merge_group" === context.eventName) {
194+
const payload = context.payload as MergeGroupEvent;
195+
commit = payload.merge_group.head_sha;
190196
}
191197

192198
debug(`Using commit: ${commit ?? null}`, { enabled: output.debug });
@@ -205,9 +211,12 @@ function _getCompareSHA(
205211

206212
let compareSha = null;
207213
const context = GitHub.context;
208-
if (["pull_request", " pull_request_target"].includes(context.eventName)) {
214+
if (["pull_request", "pull_request_target"].includes(context.eventName)) {
209215
const payload = context.payload as PullRequestEvent;
210216
compareSha = payload.pull_request.base.sha;
217+
} else if ("merge_group" === context.eventName) {
218+
const payload = context.payload as MergeGroupEvent;
219+
compareSha = payload.merge_group.base_sha;
211220
}
212221

213222
debug(`Using compareSha: ${compareSha}`, { enabled: output.debug });

packages/bundler-plugin-core/src/utils/providers/__tests__/GitHubActions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describe("GitHub Actions Params", () => {
324324
build: "2",
325325
buildURL: "https://github.com/testOrg/testRepo/actions/runs/2",
326326
commit: "test-head-sha",
327-
compareSha: null,
327+
compareSha: "test-base-sha",
328328
job: "testWorkflow",
329329
pr: "1",
330330
service: "github-actions",
@@ -383,7 +383,7 @@ describe("GitHub Actions Params", () => {
383383
build: "2",
384384
buildURL: "https://github.com/testOrg/testRepo/actions/runs/2",
385385
commit: "test-head-sha",
386-
compareSha: null,
386+
compareSha: "test-base-sha",
387387
job: "testWorkflow",
388388
pr: "1",
389389
service: "github-actions",

0 commit comments

Comments
 (0)