Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ jobs:
# E.g. 'ci.yml'. If not provided, current workflow id will be used
#
workflow-id: ''

# When using merge-group, use the previous commit in the group as the base SHA.
#
# Default: true
use-previous-merge-group-commit: ''
```

<!-- end configuration-options -->
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ inputs:
default: '.'
workflow-id:
description: 'The ID of the workflow to track or name of the file name. E.g. ci.yml. Defaults to current workflow'
use-previous-merge-group-commit:
description: 'When using merge-group, use the previous commit in the group as the base SHA'
default: 'true'

outputs:
base:
Expand Down
3 changes: 2 additions & 1 deletion dist/nx-set-shas.js
Original file line number Diff line number Diff line change
Expand Up @@ -22713,6 +22713,7 @@ var workingDirectory = core.getInput("working-directory");
var workflowId = core.getInput("workflow-id");
var fallbackSHA = core.getInput("fallback-sha");
var remote = core.getInput("remote");
var usePreviousMergeGroupCommit = core.getBooleanInput("use-previous-merge-group-commit");
var defaultWorkingDirectory = ".";
var BASE_SHA;
(async () => {
Expand All @@ -22738,7 +22739,7 @@ var BASE_SHA;
"HEAD"
], { encoding: "utf-8" });
BASE_SHA = baseResult.stdout;
} else if (eventName == "merge_group") {
} else if (eventName == "merge_group" && usePreviousMergeGroupCommit) {
const baseResult = spawnSync("git", ["rev-parse", "HEAD^1"], {
encoding: "utf-8"
});
Expand Down
5 changes: 4 additions & 1 deletion nx-set-shas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const workingDirectory = core.getInput('working-directory');
const workflowId = core.getInput('workflow-id');
const fallbackSHA = core.getInput('fallback-sha');
const remote = core.getInput('remote');
const usePreviousMergeGroupCommit = core.getBooleanInput(
'use-previous-merge-group-commit',
);
const defaultWorkingDirectory = '.';

let BASE_SHA: string;
Expand Down Expand Up @@ -56,7 +59,7 @@ let BASE_SHA: string;
{ encoding: 'utf-8' },
);
BASE_SHA = baseResult.stdout;
} else if (eventName == 'merge_group') {
} else if (eventName == 'merge_group' && usePreviousMergeGroupCommit) {
const baseResult = spawnSync('git', ['rev-parse', 'HEAD^1'], {
encoding: 'utf-8',
});
Expand Down