Skip to content

Commit

Permalink
Merge pull request #5 from fabidick22/refactor-outputs
Browse files Browse the repository at this point in the history
Rename and create new outputs
  • Loading branch information
fabidick22 authored Sep 13, 2022
2 parents 07a7eca + 74bbeda commit 89c2983
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Action to get paths and files changed in a Pull Request event and use these for
- Get list of files changed in a PR

## Usage
<details><summary><strong> Get a list of paths to use in a matrix of jobs</strong></summary>
<details><summary><strong> Get a list of paths to use in a matrix of jobs (v1)</strong></summary>

```yaml
name: 'PR Detect changes'
Expand Down Expand Up @@ -57,12 +57,10 @@ jobs:

| parameter | description |
| - | - |
| paths_changed | List of changed paths, example:
``` ["dist", "dist/data"] ```
|
| file_changed | List of changed files, example:
``` ["dist/main.tf", "dist/index.js"] ```
|
| paths_list | List of changed paths, example: `["dist", "dist/data"]` |
| file_list | List of changed files, example: `["dist/main.tf", "dist/index.js"]` |
| paths_str | List of changed paths separated by `,` example: `"dist,dist/data"` |
| file_str | List of changed files separated by `,` example: `"dist/main.tf,dist/index.js"` |



Expand Down
22 changes: 8 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ inputs:
required: false
default: ${{ github.token }}
outputs:
paths_changed:
description: >
List of changed paths, example:
```
["dist", "dist/data"]
```
file_changed:
description: >
List of changed files, example:
```
["dist/main.tf", "dist/index.js"]
```
paths_list:
description: 'List of changed paths, example: `["dist", "dist/data"]`'
file_list:
description: 'List of changed files, example: `["dist/main.tf", "dist/index.js"]`'
paths_str:
description: 'List of changed paths separated by `,` example: `"dist,dist/data"`'
file_str:
description: 'List of changed files separated by `,` example: `"dist/main.tf,dist/index.js"`'
runs:
using: 'node16'
main: 'dist/index.js'
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ async function setOutputs(files) {
pathsChanged.push(file.filename.split("/").slice(0, -1).join("/"))
filesChanged.push(file.filename)
})
core.setOutput("paths_changed", JSON.stringify([...new Set(pathsChanged)]))
core.setOutput("file_changed", JSON.stringify(filesChanged))
core.setOutput("paths_list", JSON.stringify([...new Set(pathsChanged)]))
core.setOutput("file_list", JSON.stringify([...new Set(filesChanged)]))
core.setOutput("paths_str", [...new Set(pathsChanged)].join())
core.setOutput("file_str", [...new Set(filesChanged)].join())
}

const main = async () => {
Expand All @@ -33,7 +35,7 @@ const main = async () => {
})

if (filteredFiles.length === 0) {
console.log("No matchs found.")
console.log("No matches found.")
console.log(`Raw input: ${path}`)
console.log(`Regex: ${regExp.toString()}`)
}
Expand Down

0 comments on commit 89c2983

Please sign in to comment.