Skip to content
Merged
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 .changeset/thirty-turkeys-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"advanced-triggers": major
---

feat: initial release
36 changes: 30 additions & 6 deletions actions/advanced-triggers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,36 @@ from consideration_ before any positive matching occurs.

## Inputs

| Input | Required | Default | Description |
| ----------------- | -------- | ------------------------- | ---------------------------------------------------------------- |
| `github-token` | yes | `${{ github.token }}` | GitHub token for API access (defaults to the built-in token) |
| `repository-root` | no | `${{ github.workspace }}` | Repo root directory, used for git-based diff on push/merge_group |
| `file-sets` | no | — | YAML string of named file-set pattern groups (see below) |
| `triggers` | yes | — | YAML string of named triggers (see below) |
| Input | Required | Default | Description |
| ----------------- | -------- | ------------------------- | ----------------------------------------------------------------------------------- |
| `github-token` | yes | `${{ github.token }}` | GitHub token for API access |
| `repository-root` | no | `${{ github.workspace }}` | Repo root directory, used for git-based diff on push/merge_group |
| `force-all` | no | `"false"` | When `"true"`, skips all filtering and outputs `true` for every trigger (see below) |
| `file-sets` | no | — | YAML string of named file-set pattern groups (see below) |
| `triggers` | yes | — | YAML string of named triggers (see below) |

### `force-all`

When `force-all` is `"true"`, the action skips file-change detection and trigger
evaluation entirely and outputs `true` for every configured trigger. This is
useful when you want all jobs to run unconditionally regardless of what changed
— for example on a release branch push or a tag push:

```yaml
- id: filter
uses: smartcontractkit/.github/actions/advanced-triggers@main
with:
force-all:
${{ startsWith(github.ref, 'refs/tags/') || startsWith(github.ref,
'refs/heads/release/') }}
file-sets: |
...
triggers: |
...
```

The trigger names are still parsed so their outputs are set correctly — only the
evaluation logic is bypassed.

## Outputs

Expand Down
9 changes: 9 additions & 0 deletions actions/advanced-triggers/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ inputs:
"exclusion-sets" (excluded before positive matching).
required: false

force-all:
description: |
When set to "true", skips all file-change detection and trigger evaluation
and outputs true for every configured trigger. Use this to unconditionally
run all jobs — for example when pushing to a release branch or a tag.
Defaults to "false".
default: "false"
required: false

triggers:
description: |
A YAML string defining named triggers. Each trigger is a mapping with optional
Expand Down
44 changes: 41 additions & 3 deletions actions/advanced-triggers/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33684,6 +33684,7 @@ function getEventData() {
function getInputs() {
info("Getting inputs for run.");
const inputs = {
forceAll: getRunInputString("forceAll", false),
fileSets: getRunInputString("fileSets", false),
triggers: getRunInputString("triggers", true),
repositoryRoot: getRunInputString("repositoryRoot", true)
Expand Down Expand Up @@ -33712,6 +33713,11 @@ function getInvokeContext() {
return { token, owner, repo, event };
}
var runInputsConfiguration = {
forceAll: {
parameter: "force-all",
localParameter: "FORCE_ALL",
validator: (v) => v === "true" || v === "false"
},
fileSets: {
parameter: "file-sets",
localParameter: "FILE_SETS"
Expand Down Expand Up @@ -47555,12 +47561,18 @@ var triggerConfigSchema = external_exports.object({
*/
alwaysTriggerOn: external_exports.array(external_exports.string())
});
var ALLOWED_TRIGGER_KEYS = /* @__PURE__ */ new Set([
"inclusion-sets",
"exclusion-sets",
"paths",
"always-trigger-on"
]);
var triggerRawSchema = external_exports.object({
"inclusion-sets": external_exports.array(external_exports.string()).optional(),
"exclusion-sets": external_exports.array(external_exports.string()).optional(),
paths: external_exports.array(external_exports.string()).optional(),
"always-trigger-on": external_exports.array(external_exports.string()).optional()
}).strict();
}).passthrough();
function buildTriggersSchema(fileSets) {
return external_exports.record(external_exports.string(), triggerRawSchema).superRefine((triggers, ctx) => {
if (Object.keys(triggers).length === 0) {
Expand All @@ -47571,6 +47583,15 @@ function buildTriggersSchema(fileSets) {
return;
}
for (const [name, config2] of Object.entries(triggers)) {
for (const key of Object.keys(config2)) {
if (!ALLOWED_TRIGGER_KEYS.has(key)) {
ctx.addIssue({
code: "custom",
path: [name, key],
message: `Unknown key "${key}". Allowed keys: "inclusion-sets", "exclusion-sets", "paths", "always-trigger-on".`
});
}
}
validateTrigger(name, config2, fileSets, ctx);
}
});
Expand All @@ -47581,7 +47602,7 @@ function validateTrigger(name, config2, fileSets, ctx) {
ctx.addIssue({
code: "custom",
path: [name, "inclusion-sets", i],
message: `Unknown file-set "${setName}".`
message: `unknown file-set "${setName}" in "inclusion-sets".`
});
}
}
Expand All @@ -47590,7 +47611,7 @@ function validateTrigger(name, config2, fileSets, ctx) {
ctx.addIssue({
code: "custom",
path: [name, "exclusion-sets", i],
message: `Unknown file-set "${setName}".`
message: `unknown file-set "${setName}" in "exclusion-sets".`
});
}
}
Expand Down Expand Up @@ -47832,6 +47853,23 @@ async function run() {
`Parsed ${triggers.length} trigger(s): ${triggers.map((t) => t.name).join(", ")}`
);
endGroup();
if (inputs.forceAll === "true") {
startGroup("force-all override");
info(
"force-all is true \u2014 skipping file matching, all triggers set to matched."
);
const triggerResults2 = triggers.map((t) => ({
name: t.name,
matched: true,
candidateCount: 0,
matchedFiles: []
}));
endGroup();
startGroup("Setting outputs");
setOutputs({ triggerResults: triggerResults2 });
endGroup();
return;
}
startGroup("Determining changed files");
info(`Event type: ${context3.event.eventName}`);
let changedFiles = null;
Expand Down
Loading
Loading