1414
1515permissions :
1616 contents : read
17- pull-requests : read
1817
1918jobs :
2019 scope :
2322 outputs :
2423 should-scan : ${{ steps.scope.outputs.should-scan }}
2524 steps :
25+ - name : Checkout
26+ if : github.event_name == 'pull_request' && github.event.pull_request.draft == false
27+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
28+ with :
29+ fetch-depth : 1
30+ fetch-tags : false
31+ persist-credentials : false
32+ submodules : false
33+
34+ - name : Ensure base commit
35+ if : github.event_name == 'pull_request' && github.event.pull_request.draft == false
36+ uses : ./.github/actions/ensure-base-commit
37+ with :
38+ base-sha : ${{ github.event.pull_request.base.sha }}
39+ fetch-ref : ${{ github.event.pull_request.base.ref }}
40+
2641 - name : Detect changed paths
2742 id : scope
2843 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
@@ -37,32 +52,33 @@ jobs:
3752 return;
3853 }
3954
40- const files = await github.paginate(github.rest.pulls.listFiles, {
41- owner: context.repo.owner,
42- repo: context.repo.repo,
43- pull_number: context.payload.pull_request.number,
44- per_page: 100,
45- });
46- const isScanPath = (filename) =>
47- typeof filename === "string" && (
48- filename.startsWith("apps/ios/") ||
49- filename.startsWith("apps/shared/OpenClawKit/Sources/") ||
50- filename.startsWith("apps/swabble/Sources/SwabbleKit/") ||
51- filename === ".github/workflows/ios-periphery.yml" ||
52- filename === ".github/workflows/ios-periphery-comment.yml" ||
53- filename === "config/swiftformat" ||
54- filename === "config/swiftlint.yml" ||
55- filename === "scripts/check-swift-tools.sh" ||
56- filename === "scripts/format-swift.sh" ||
57- filename === "scripts/install-swift-tools.sh" ||
58- filename === "scripts/ios-write-swift-filelist.mjs" ||
59- filename === "scripts/lint-swift.sh"
60- );
61- const shouldScan = files.some(
62- ({ filename, previous_filename: previousFilename }) =>
63- isScanPath(filename) || isScanPath(previousFilename)
64- );
65- core.setOutput("should-scan", String(shouldScan));
55+ const baseSha = context.payload.pull_request?.base?.sha;
56+ if (!baseSha) {
57+ throw new Error("missing pull request base SHA");
58+ }
59+ const result = await exec.getExecOutput("git", [
60+ "diff",
61+ "--quiet",
62+ baseSha,
63+ "HEAD",
64+ "--",
65+ "apps/ios/",
66+ "apps/shared/OpenClawKit/Sources/",
67+ "apps/swabble/Sources/SwabbleKit/",
68+ ".github/workflows/ios-periphery.yml",
69+ ".github/workflows/ios-periphery-comment.yml",
70+ "config/swiftformat",
71+ "config/swiftlint.yml",
72+ "scripts/check-swift-tools.sh",
73+ "scripts/format-swift.sh",
74+ "scripts/install-swift-tools.sh",
75+ "scripts/ios-write-swift-filelist.mjs",
76+ "scripts/lint-swift.sh",
77+ ], { ignoreReturnCode: true, silent: true });
78+ if (result.exitCode !== 0 && result.exitCode !== 1) {
79+ throw new Error(`git diff failed with exit code ${result.exitCode}`);
80+ }
81+ core.setOutput("should-scan", String(result.exitCode === 1));
6682
6783 scan :
6884 name : Scan iOS dead code
0 commit comments