Skip to content

Commit 3ad22cf

Browse files
fix(lint): get changed files via rest API
1 parent 0994f0c commit 3ad22cf

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

.github/workflows/__call-common-lint.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ jobs:
2525
steps:
2626
- name: Checkout
2727
uses: actions/checkout@v5
28-
with:
29-
fetch-depth: 2 # need to fetch 2 to get list of changed files
3028

3129
- name: Get changed files
3230
id: changed_files
33-
shell: bash
34-
run: |
35-
firstCommit='${{ github.event.pull_request.base.sha }}'
36-
lastCommit='${{ github.event.pull_request.head.sha }}'
37-
changedFiles=$(git diff --name-only --diff-filter=d "${firstCommit}" "${lastCommit}" | tr '\n' ' ')
38-
39-
echo "Changed files: ${changedFiles}"
40-
echo "CHANGED_FILES=${changedFiles}" >> "${GITHUB_OUTPUT}"
31+
uses: actions/github-script@v7
32+
with:
33+
script: |
34+
const opts = github.rest.pulls.listFiles.endpoint.merge({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
pull_number: context.issue.number,
38+
});
39+
const changedFiles = await github.paginate(opts);
40+
const changedFilesString = changedFiles.map(file => file.filename).join(' ');
41+
console.log(`Changed files: ${changedFilesString}`);
42+
core.setOutput('CHANGED_FILES', changedFilesString);
4143
4244
- name: Download problem matchers
4345
shell: bash

0 commit comments

Comments
 (0)