Skip to content

Commit 5a64727

Browse files
authored
ci: add dependency guard backfill label trigger (#87866)
1 parent fd64313 commit 5a64727

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/dependency-guard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Dependency Guard
22

33
on:
44
pull_request_target: # zizmor: ignore[dangerous-triggers] checks trusted base script only; never checks out PR head
5-
types: [opened, reopened, synchronize, ready_for_review]
5+
types: [opened, reopened, synchronize, ready_for_review, labeled]
66

77
permissions:
88
contents: read
@@ -15,7 +15,7 @@ concurrency:
1515

1616
jobs:
1717
dependency-guard:
18-
if: ${{ !github.event.pull_request.draft }}
18+
if: ${{ !github.event.pull_request.draft && (github.event.action != 'labeled' || github.event.label.name == 'dependency-guard-backfill') }}
1919
runs-on: ubuntu-24.04
2020
timeout-minutes: 5
2121
steps:

test/scripts/dependency-guard-workflow.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ type WorkflowStep = {
1313
};
1414

1515
type WorkflowJob = {
16+
if?: string;
1617
name?: string;
1718
steps?: WorkflowStep[];
1819
};
1920

2021
type Workflow = {
2122
jobs?: Record<string, WorkflowJob>;
2223
name?: string;
24+
on?: {
25+
pull_request_target?: {
26+
types?: string[];
27+
};
28+
};
2329
permissions?: Record<string, string>;
2430
};
2531

@@ -36,6 +42,21 @@ describe("dependency guard workflow", () => {
3642
expect(parsed.jobs?.["dependency-guard"]?.name).toBeUndefined();
3743
});
3844

45+
it("allows one temporary label trigger for required-check backfill", () => {
46+
const parsed = readWorkflow();
47+
const job = parsed.jobs?.["dependency-guard"];
48+
49+
expect(parsed.on?.pull_request_target?.types).toEqual([
50+
"opened",
51+
"reopened",
52+
"synchronize",
53+
"ready_for_review",
54+
"labeled",
55+
]);
56+
expect(job?.if).toContain("github.event.action != 'labeled'");
57+
expect(job?.if).toContain("github.event.label.name == 'dependency-guard-backfill'");
58+
});
59+
3960
it("uses a metadata-only pull_request_target workflow with minimal write permissions", () => {
4061
const workflow = readFileSync(WORKFLOW, "utf8");
4162
const parsed = readWorkflow();

0 commit comments

Comments
 (0)