Skip to content

Commit 8ff5bf9

Browse files
committed
feat: force-all input
1 parent bf0f436 commit 8ff5bf9

5 files changed

Lines changed: 110 additions & 12 deletions

File tree

actions/advanced-triggers/README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,36 @@ from consideration_ before any positive matching occurs.
9696

9797
## Inputs
9898

99-
| Input | Required | Default | Description |
100-
| ----------------- | -------- | ------------------------- | ---------------------------------------------------------------- |
101-
| `github-token` | yes | `${{ github.token }}` | GitHub token for API access (defaults to the built-in token) |
102-
| `repository-root` | no | `${{ github.workspace }}` | Repo root directory, used for git-based diff on push/merge_group |
103-
| `file-sets` | no | — | YAML string of named file-set pattern groups (see below) |
104-
| `triggers` | yes | — | YAML string of named triggers (see below) |
99+
| Input | Required | Default | Description |
100+
| ----------------- | -------- | ------------------------- | ----------------------------------------------------------------------------------- |
101+
| `github-token` | yes | `${{ github.token }}` | GitHub token for API access |
102+
| `repository-root` | no | `${{ github.workspace }}` | Repo root directory, used for git-based diff on push/merge_group |
103+
| `force-all` | no | `"false"` | When `"true"`, skips all filtering and outputs `true` for every trigger (see below) |
104+
| `file-sets` | no | — | YAML string of named file-set pattern groups (see below) |
105+
| `triggers` | yes | — | YAML string of named triggers (see below) |
106+
107+
### `force-all`
108+
109+
When `force-all` is `"true"`, the action skips file-change detection and trigger
110+
evaluation entirely and outputs `true` for every configured trigger. This is
111+
useful when you want all jobs to run unconditionally regardless of what changed
112+
— for example on a release branch push or a tag push:
113+
114+
```yaml
115+
- id: filter
116+
uses: smartcontractkit/.github/actions/advanced-triggers@main
117+
with:
118+
force-all:
119+
${{ startsWith(github.ref, 'refs/tags/') || startsWith(github.ref,
120+
'refs/heads/release/') }}
121+
file-sets: |
122+
...
123+
triggers: |
124+
...
125+
```
126+
127+
The trigger names are still parsed so their outputs are set correctly — only the
128+
evaluation logic is bypassed.
105129

106130
## Outputs
107131

actions/advanced-triggers/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ inputs:
2424
"exclusion-sets" (excluded before positive matching).
2525
required: false
2626

27+
force-all:
28+
description: |
29+
When set to "true", skips all file-change detection and trigger evaluation
30+
and outputs true for every configured trigger. Use this to unconditionally
31+
run all jobs — for example when pushing to a release branch or a tag.
32+
Defaults to "false".
33+
default: "false"
34+
required: false
35+
2736
triggers:
2837
description: |
2938
A YAML string defining named triggers. Each trigger is a mapping with optional

actions/advanced-triggers/dist/index.js

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33684,6 +33684,7 @@ function getEventData() {
3368433684
function getInputs() {
3368533685
info("Getting inputs for run.");
3368633686
const inputs = {
33687+
forceAll: getRunInputString("forceAll", false),
3368733688
fileSets: getRunInputString("fileSets", false),
3368833689
triggers: getRunInputString("triggers", true),
3368933690
repositoryRoot: getRunInputString("repositoryRoot", true)
@@ -33712,6 +33713,11 @@ function getInvokeContext() {
3371233713
return { token, owner, repo, event };
3371333714
}
3371433715
var runInputsConfiguration = {
33716+
forceAll: {
33717+
parameter: "force-all",
33718+
localParameter: "FORCE_ALL",
33719+
validator: (v) => v === "true" || v === "false"
33720+
},
3371533721
fileSets: {
3371633722
parameter: "file-sets",
3371733723
localParameter: "FILE_SETS"
@@ -47555,12 +47561,18 @@ var triggerConfigSchema = external_exports.object({
4755547561
*/
4755647562
alwaysTriggerOn: external_exports.array(external_exports.string())
4755747563
});
47564+
var ALLOWED_TRIGGER_KEYS = /* @__PURE__ */ new Set([
47565+
"inclusion-sets",
47566+
"exclusion-sets",
47567+
"paths",
47568+
"always-trigger-on"
47569+
]);
4755847570
var triggerRawSchema = external_exports.object({
4755947571
"inclusion-sets": external_exports.array(external_exports.string()).optional(),
4756047572
"exclusion-sets": external_exports.array(external_exports.string()).optional(),
4756147573
paths: external_exports.array(external_exports.string()).optional(),
4756247574
"always-trigger-on": external_exports.array(external_exports.string()).optional()
47563-
}).strict();
47575+
}).passthrough();
4756447576
function buildTriggersSchema(fileSets) {
4756547577
return external_exports.record(external_exports.string(), triggerRawSchema).superRefine((triggers, ctx) => {
4756647578
if (Object.keys(triggers).length === 0) {
@@ -47571,6 +47583,15 @@ function buildTriggersSchema(fileSets) {
4757147583
return;
4757247584
}
4757347585
for (const [name, config2] of Object.entries(triggers)) {
47586+
for (const key of Object.keys(config2)) {
47587+
if (!ALLOWED_TRIGGER_KEYS.has(key)) {
47588+
ctx.addIssue({
47589+
code: "custom",
47590+
path: [name, key],
47591+
message: `Unknown key "${key}". Allowed keys: "inclusion-sets", "exclusion-sets", "paths", "always-trigger-on".`
47592+
});
47593+
}
47594+
}
4757447595
validateTrigger(name, config2, fileSets, ctx);
4757547596
}
4757647597
});
@@ -47581,7 +47602,7 @@ function validateTrigger(name, config2, fileSets, ctx) {
4758147602
ctx.addIssue({
4758247603
code: "custom",
4758347604
path: [name, "inclusion-sets", i],
47584-
message: `Unknown file-set "${setName}".`
47605+
message: `unknown file-set "${setName}" in "inclusion-sets".`
4758547606
});
4758647607
}
4758747608
}
@@ -47590,7 +47611,7 @@ function validateTrigger(name, config2, fileSets, ctx) {
4759047611
ctx.addIssue({
4759147612
code: "custom",
4759247613
path: [name, "exclusion-sets", i],
47593-
message: `Unknown file-set "${setName}".`
47614+
message: `unknown file-set "${setName}" in "exclusion-sets".`
4759447615
});
4759547616
}
4759647617
}
@@ -47832,6 +47853,23 @@ async function run() {
4783247853
`Parsed ${triggers.length} trigger(s): ${triggers.map((t) => t.name).join(", ")}`
4783347854
);
4783447855
endGroup();
47856+
if (inputs.forceAll === "true") {
47857+
startGroup("force-all override");
47858+
info(
47859+
"force-all is true \u2014 skipping file matching, all triggers set to matched."
47860+
);
47861+
const triggerResults2 = triggers.map((t) => ({
47862+
name: t.name,
47863+
matched: true,
47864+
candidateCount: 0,
47865+
matchedFiles: []
47866+
}));
47867+
endGroup();
47868+
startGroup("Setting outputs");
47869+
setOutputs({ triggerResults: triggerResults2 });
47870+
endGroup();
47871+
return;
47872+
}
4783547873
startGroup("Determining changed files");
4783647874
info(`Event type: ${context3.event.eventName}`);
4783747875
let changedFiles = null;

actions/advanced-triggers/src/run-inputs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as github from "@actions/github";
44
import { getEventData } from "./event";
55

66
export interface RunInputs {
7+
forceAll: string;
78
fileSets: string;
89
triggers: string;
910
repositoryRoot: string;
@@ -15,6 +16,7 @@ export function getInputs(): RunInputs {
1516
core.info("Getting inputs for run.");
1617

1718
const inputs: RunInputs = {
19+
forceAll: getRunInputString("forceAll", false),
1820
fileSets: getRunInputString("fileSets", false),
1921
triggers: getRunInputString("triggers", true),
2022
repositoryRoot: getRunInputString("repositoryRoot", true),
@@ -81,6 +83,11 @@ interface RunInputConfiguration {
8183
const runInputsConfiguration: {
8284
[K in keyof RunInputs]: RunInputConfiguration;
8385
} = {
86+
forceAll: {
87+
parameter: "force-all",
88+
localParameter: "FORCE_ALL",
89+
validator: (v) => v === "true" || v === "false",
90+
},
8491
fileSets: {
8592
parameter: "file-sets",
8693
localParameter: "FILE_SETS",

actions/advanced-triggers/src/run.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,27 @@ export async function run(): Promise<void> {
6969
);
7070
core.endGroup();
7171

72-
// 3. Determine changed files for file-change events.
72+
// 3. Short-circuit if force-all is set.
73+
if (inputs.forceAll === "true") {
74+
core.startGroup("force-all override");
75+
core.info(
76+
"force-all is true — skipping file matching, all triggers set to matched.",
77+
);
78+
const triggerResults = triggers.map((t) => ({
79+
name: t.name,
80+
matched: true,
81+
candidateCount: 0,
82+
matchedFiles: [],
83+
}));
84+
core.endGroup();
85+
core.startGroup("Setting outputs");
86+
setOutputs({ triggerResults });
87+
core.endGroup();
88+
return;
89+
}
90+
91+
// 4. Determine changed files for file-change events.
92+
7393
core.startGroup("Determining changed files");
7494
core.info(`Event type: ${context.event.eventName}`);
7595
let changedFiles: string[] | null = null;
@@ -91,7 +111,7 @@ export async function run(): Promise<void> {
91111
}
92112
core.endGroup();
93113

94-
// 4. Apply each trigger.
114+
// 5. Apply each trigger.
95115
core.startGroup("Applying triggers");
96116
const triggerResults: TriggerResult[] = [];
97117
for (const trigger of triggers) {
@@ -127,7 +147,7 @@ export async function run(): Promise<void> {
127147
}
128148
core.endGroup();
129149

130-
// 5. Set outputs.
150+
// 6. Set outputs.
131151
core.startGroup("Setting outputs");
132152
setOutputs({ triggerResults });
133153
core.endGroup();

0 commit comments

Comments
 (0)