7 Commits

Author SHA1 Message Date
Michal Dorner
ebc4d7e9eb Update CHANGELOG for v3.0.1 2024-02-15 09:20:42 +01:00
Michal Dorner
45f16f1875 Merge pull request #133 from frouioui/main
Compare base and ref when token is empty
2024-02-15 09:15:48 +01:00
Michal Dorner
5da0e4c086 Merge branch 'master' 2024-02-15 09:13:51 +01:00
Michal Dorner
1441771bbf Update README.md
Add info about v3 release to What's New section
2024-01-25 08:13:18 +01:00
Michal Dorner
0bc4621a31 Bump major version to v3
Node version has been updated to 20 which might be a breaking change.
2024-01-25 07:48:07 +01:00
Florent Poinsard
245527a2ef Merge remote-tracking branch 'upstream/master' 2022-10-26 15:40:33 +02:00
Florent Poinsard
5266f0ac59 Compare base and ref when token is empty
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
2022-04-19 14:29:04 +02:00
4 changed files with 31 additions and 20 deletions

View File

@@ -1,7 +1,10 @@
# Changelog
## v2.12.0
- [Update to Node.js 20 ](https://github.com/dorny/paths-filter/pull/210)
## v3.0.1
- [Compare base and ref when token is empty](https://github.com/dorny/paths-filter/pull/133)
## v3.0.0
- [Update to Node.js 20](https://github.com/dorny/paths-filter/pull/210)
- [Update all dependencies](https://github.com/dorny/paths-filter/pull/215)
## v2.11.1

View File

@@ -46,7 +46,7 @@ don't allow this because they don't work on a level of individual jobs or steps.
## Example
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
@@ -72,6 +72,7 @@ For more scenarios see [examples](#examples) section.
## What's New
- New major release `v3` after update to Node 20 [Breaking change]
- Add `ref` input parameter
- Add `list-files: csv` format
- Configure matrix job to run for each folder with changes using `changes` output
@@ -83,7 +84,7 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob
## Usage
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
with:
# Defines filters applied to detected changed files.
# Each filter has a name and a list of rules.
@@ -176,7 +177,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
@@ -220,7 +221,7 @@ jobs:
frontend: ${{ steps.filter.outputs.frontend }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
@@ -266,7 +267,7 @@ jobs:
packages: ${{ steps.filter.outputs.changes }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
@@ -308,7 +309,7 @@ jobs:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: ... # Configure your filters
@@ -333,7 +334,7 @@ jobs:
# This may save additional git fetch roundtrip if
# merge-base is found within latest 20 commits
fetch-depth: 20
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
base: develop # Change detection against merge-base with this branch
@@ -357,7 +358,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
# Use context to get the branch where commits were pushed.
@@ -391,7 +392,7 @@ jobs:
# Filter to detect which files were modified
# Changes could be, for example, automatically committed
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
base: HEAD
@@ -406,7 +407,7 @@ jobs:
<summary>Define filter rules in own file</summary>
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
# Path to file where filters are defined
@@ -419,7 +420,7 @@ jobs:
<summary>Use YAML anchors to reuse path expression(s) inside another rule</summary>
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
# &shared is YAML anchor,
@@ -440,7 +441,7 @@ jobs:
<summary>Consider if file was added, modified or deleted</summary>
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
# Changed file can be 'added', 'modified', or 'deleted'.
@@ -468,7 +469,7 @@ jobs:
<summary>Passing list of modified files as command line args in Linux shell</summary>
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
# Enable listing of files matching each filter.
@@ -494,7 +495,7 @@ jobs:
<summary>Passing list of modified files as JSON array to another action</summary>
```yaml
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
# Enable listing of files matching each filter.

8
dist/index.js vendored
View File

@@ -555,6 +555,7 @@ function getConfigFileContent(configPath) {
return fs.readFileSync(configPath, { encoding: 'utf8' });
}
async function getChangedFiles(token, base, ref, initialFetchDepth) {
var _a, _b;
// if base is 'HEAD' only local uncommitted changes will be detected
// This is the simplest case as we don't need to fetch more commits or evaluate current/before refs
if (base === git.HEAD) {
@@ -581,8 +582,11 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) {
// At the same time we don't want to fetch any code from forked repository
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`);
}
core.info('Github token is not available - changes will be detected from PRs merge commit');
return await git.getChangesInLastCommit();
core.info('Github token is not available - changes will be detected using git diff');
const baseSha = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha;
const defaultBranch = (_b = github.context.payload.repository) === null || _b === void 0 ? void 0 : _b.default_branch;
const currentRef = await git.getCurrentRef();
return await git.getChanges(base || baseSha || defaultBranch, currentRef);
}
else {
return getChangedFilesFromGit(base, ref, initialFetchDepth);

View File

@@ -86,8 +86,11 @@ async function getChangedFiles(token: string, base: string, ref: string, initial
// At the same time we don't want to fetch any code from forked repository
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`)
}
core.info('Github token is not available - changes will be detected from PRs merge commit')
return await git.getChangesInLastCommit()
core.info('Github token is not available - changes will be detected using git diff')
const baseSha = github.context.payload.pull_request?.base.sha
const defaultBranch = github.context.payload.repository?.default_branch
const currentRef = await git.getCurrentRef()
return await git.getChanges(base || baseSha || defaultBranch, currentRef)
} else {
return getChangedFilesFromGit(base, ref, initialFetchDepth)
}