@@ -8865,30 +8865,35 @@ const github = __nccwpck_require__(5438);
8865
8865
8866
8866
const main = async () => {
8867
8867
try {
8868
- const owner = core.getInput('paths ', { required: true });
8868
+ const path = core.getInput('path ', { required: true });
8869
8869
const token = core.getInput('token', { required: true });
8870
+ const regExp = RegExp(path)
8870
8871
const octokit = new github.getOctokit(token);
8871
8872
8872
- const { data: changedFiles } = await octokit.rest.pulls.listFiles({
8873
- owner,
8874
- repo,
8875
- pull_number: pr_number,
8876
- });
8873
+ const response = await octokit.rest.repos.compareCommits({
8874
+ owner: github.context.repo.owner,
8875
+ repo: github.context.repo.repo,
8876
+ base: "HEAD^",
8877
+ head: "HEAD"
8878
+ })
8877
8879
8878
- let diffData = {
8879
- additions: 0,
8880
- deletions: 0,
8881
- changes: 0
8882
- };
8880
+ const filteredFiles = (response.data.files || []).filter(file => {
8881
+ let isMatch = regExp.test(file.filename)
8882
+ console.log(`[${isMatch && '[** match **]'} ${file.filename}`)
8883
+ console.log(`##Path: ${file.filename} matches`)
8884
+ return isMatch
8885
+ })
8886
+
8887
+ if(filteredFiles.length === 0){
8888
+ console.log("No matchs found.")
8889
+ console.log(`Raw input: ${directory}`)
8890
+ console.log(`Regex: ${regExp.toString()}`)
8891
+ core.setOutput("hasChanges", false)
8892
+ }
8883
8893
8884
- diffData = changedFiles.reduce((acc, file) => {
8885
- acc.additions += file.additions;
8886
- acc.deletions += file.deletions;
8887
- acc.changes += file.changes;
8888
- return acc;
8889
- }, diffData);
8894
+ console.log(`Found a total of ${filteredFiles.length} matches`)
8890
8895
8891
- console.log(changedFiles);
8896
+ core.setOutput("hasChanges", true)
8892
8897
8893
8898
} catch (error) {
8894
8899
core.setFailed(error.message);
0 commit comments