Skip to content

Commit 6567940

Browse files
authored
Fix: Update merge-group behaviour to support additional merge queue configurations (#203)
1 parent 9885af3 commit 6567940

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ jobs:
118118
# E.g. 'ci.yml'. If not provided, current workflow id will be used
119119
#
120120
workflow-id: ''
121+
122+
# When using merge-group, use the previous commit in the group as the base SHA.
123+
#
124+
# Default: true
125+
use-previous-merge-group-commit: ''
121126
```
122127
123128
<!-- end configuration-options -->

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ inputs:
2929
default: '.'
3030
workflow-id:
3131
description: 'The ID of the workflow to track or name of the file name. E.g. ci.yml. Defaults to current workflow'
32+
use-previous-merge-group-commit:
33+
description: 'When using merge-group, use the previous commit in the group as the base SHA'
34+
default: 'true'
3235

3336
outputs:
3437
base:

dist/nx-set-shas.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22713,6 +22713,7 @@ var workingDirectory = core.getInput("working-directory");
2271322713
var workflowId = core.getInput("workflow-id");
2271422714
var fallbackSHA = core.getInput("fallback-sha");
2271522715
var remote = core.getInput("remote");
22716+
var usePreviousMergeGroupCommit = core.getBooleanInput("use-previous-merge-group-commit");
2271622717
var defaultWorkingDirectory = ".";
2271722718
var BASE_SHA;
2271822719
(async () => {
@@ -22738,7 +22739,7 @@ var BASE_SHA;
2273822739
"HEAD"
2273922740
], { encoding: "utf-8" });
2274022741
BASE_SHA = baseResult.stdout;
22741-
} else if (eventName == "merge_group") {
22742+
} else if (eventName == "merge_group" && usePreviousMergeGroupCommit) {
2274222743
const baseResult = spawnSync("git", ["rev-parse", "HEAD^1"], {
2274322744
encoding: "utf-8"
2274422745
});

nx-set-shas.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const workingDirectory = core.getInput('working-directory');
1919
const workflowId = core.getInput('workflow-id');
2020
const fallbackSHA = core.getInput('fallback-sha');
2121
const remote = core.getInput('remote');
22+
const usePreviousMergeGroupCommit = core.getBooleanInput(
23+
'use-previous-merge-group-commit',
24+
);
2225
const defaultWorkingDirectory = '.';
2326

2427
let BASE_SHA: string;
@@ -56,7 +59,7 @@ let BASE_SHA: string;
5659
{ encoding: 'utf-8' },
5760
);
5861
BASE_SHA = baseResult.stdout;
59-
} else if (eventName == 'merge_group') {
62+
} else if (eventName == 'merge_group' && usePreviousMergeGroupCommit) {
6063
const baseResult = spawnSync('git', ['rev-parse', 'HEAD^1'], {
6164
encoding: 'utf-8',
6265
});

0 commit comments

Comments
 (0)