| 1 | # Check if the path of changed file is longer than 260 characters |
| 2 | # that windows filesystem allows |
| 3 | |
| 4 | name: Detect long path among changed files |
| 5 | |
| 6 | on: |
| 7 | workflow_dispatch: |
| 8 | pull_request: # focus on the changed files in current PR |
| 9 | branches: ["main", "features/**", "release-**"] |
| 10 | |
| 11 | permissions: {} |
| 12 | |
| 13 | concurrency: |
| 14 | group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | cancel-in-progress: true |
| 16 | |
| 17 | jobs: |
| 18 | long-path: |
| 19 | runs-on: ubuntu-latest |
| 20 | |
| 21 | steps: |
| 22 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 23 | with: |
| 24 | persist-credentials: false |
| 25 | - name: Check for changed files |
| 26 | id: changed-files |
| 27 | uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6 |
| 28 | - name: Detect long path |
| 29 | env: |
| 30 | ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} # ignore the deleted files |
| 31 | MAX_LENGTH: 120 # set max length to 120, considering the base path of app project that uses matrix-sdk |
| 32 | run: | |
| 33 | for file in ${ALL_CHANGED_FILES}; do |
| 34 | if [ ${#file} -gt $MAX_LENGTH ]; then |
| 35 | echo "File path is too long. Length: ${#file}, Path: $file" |
| 36 | exit 1 |
| 37 | fi |
| 38 | done |
| 39 | exit 0 |