|
| 1 | +# Get Changed Paths |
| 2 | + |
| 3 | +This action detects the deepest path of the modified file in PR.It also provides some features to assist in handling pull requests |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +Returns the deepest path to the file changed by the pull request |
| 8 | + |
| 9 | +### First |
| 10 | + |
| 11 | +Create a workflow `paths.yml` file in your repositories `.github/workflows `directory. |
| 12 | + |
| 13 | +### Inputs |
| 14 | + |
| 15 | +#### github-token |
| 16 | + |
| 17 | +The GitHub Actions token. e.g. `secrets.PATHS_TOKEN`. For more information,See this link: [Creating a personal access token](https://docs.github.com/cn/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) |
| 18 | + |
| 19 | +#### ignore |
| 20 | + |
| 21 | +The paths what you want to ignore in this repository. Different paths must be separated by commas. For example: |
| 22 | + |
| 23 | +~~~bash |
| 24 | +github.com/user_test/test/ |
| 25 | +├── go.mod |
| 26 | +├── main.go |
| 27 | +├── main_test.go |
| 28 | +└── src |
| 29 | + ├── git |
| 30 | + │ ├── git.go |
| 31 | + │ └── git_test.go |
| 32 | + ├── src_test.go |
| 33 | + ├── te |
| 34 | + │ └── test.go |
| 35 | + └── ut |
| 36 | + ├── ut.go |
| 37 | + └── ut_test.go |
| 38 | +~~~ |
| 39 | + |
| 40 | +You can use `/` to ignore the `root` directory. If you use it, the action will not output `github.com/user_test/test`. |
| 41 | + |
| 42 | +You also can use `//` to ignore all directories. |
| 43 | + |
| 44 | +You can use `src/ut` to ignore `github.com/user_test/test/src/ut` directory. If you use it, the action will not output `github.com/user_test/test/src/ut` |
| 45 | + |
| 46 | +If you use `src/ut/`, the action will not output `github.com/user_test/test/src/ut` and all subdirectories. |
| 47 | + |
| 48 | +`warning`: If the corresponding ignore rule is not set, the subdirectory will still be output. |
| 49 | + |
| 50 | +For example: |
| 51 | + |
| 52 | +- The paths of modified files: `github.com/user_test/test`,` github.com/user_test/test/src`,`github.com/user_test/test/src/ut` |
| 53 | +- The ignore rules: `"/,src"` |
| 54 | +- The final output paths: `github.com/user_test/test/src/ut` |
| 55 | + |
| 56 | +### Outputs |
| 57 | + |
| 58 | +#### paths |
| 59 | + |
| 60 | +The final path filtered by the rules set earlier. For Example: `github.com/user_test/test/src/ut` |
| 61 | + |
| 62 | +#### resource |
| 63 | + |
| 64 | +The forked repository that create the now pull request. |
| 65 | + |
| 66 | +#### branch |
| 67 | + |
| 68 | +The Nnme of the branch used to create the pull request |
| 69 | + |
| 70 | +## Examples |
| 71 | + |
| 72 | +~~~yaml |
| 73 | +on: |
| 74 | + pull_request_target: |
| 75 | + types: [opened, synchronize] |
| 76 | + branches: [ "master" ] |
| 77 | + |
| 78 | + workflow_dispatch: |
| 79 | + |
| 80 | +jobs: |
| 81 | + test-name: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + name: Get Change Paths |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Get Changed Paths |
| 87 | + uses: guguducken/ut-pr-action@v0.0.4 |
| 88 | + id: paths-pr |
| 89 | + with: |
| 90 | + github-token: ${{ secrets.YOUR_TOKEN }} |
| 91 | + ignore: "" |
| 92 | + - name: Print Paths |
| 93 | + run: | |
| 94 | + echo ${{ steps.paths-pr.outputs.paths }} |
| 95 | +~~~ |
| 96 | + |
| 97 | +# License |
| 98 | + |
| 99 | +The scripts and documentation in this project are released under the [MIT License](https://github.com/guguducken/change-paths-action/blob/master/LICENSE) |
0 commit comments