|
9 | 9 | jobs:
|
10 | 10 | paths-filter:
|
11 | 11 | runs-on: ubuntu-latest
|
| 12 | + permissions: |
| 13 | + contents: read |
12 | 14 | outputs:
|
13 |
| - java: ${{ steps.filter.outputs.java }} |
14 |
| - cpp: ${{ steps.filter.outputs.cpp }} |
15 |
| - golang: ${{ steps.filter.outputs.golang }} |
16 |
| - csharp: ${{ steps.filter.outputs.csharp }} |
17 |
| - php: ${{ steps.filter.outputs.php }} |
18 |
| - rust: ${{ steps.filter.outputs.rust }} |
19 |
| - python: ${{ steps.filter.outputs.python }} |
20 |
| - nodejs: ${{ steps.filter.outputs.nodejs }} |
| 15 | + java: ${{ steps.java.outputs.java }} |
| 16 | + cpp: ${{ steps.cpp.outputs.cpp }} |
| 17 | + golang: ${{ steps.golang.outputs.golang }} |
| 18 | + csharp: ${{ steps.csharp.outputs.csharp }} |
| 19 | + php: ${{ steps.php.outputs.php }} |
| 20 | + rust: ${{ steps.rust.outputs.rust }} |
| 21 | + python: ${{ steps.python.outputs.python }} |
| 22 | + nodejs: ${{ steps.nodejs.outputs.nodejs }} |
21 | 23 | steps:
|
22 |
| - - uses: actions/checkout@v2 |
23 |
| - - uses: dorny/paths-filter@v2 |
24 |
| - id: filter |
25 |
| - with: |
26 |
| - filters: | |
27 |
| - java: |
28 |
| - - 'java/**' |
29 |
| - cpp: |
30 |
| - - 'cpp/**' |
31 |
| - golang: |
32 |
| - - 'golang/**' |
33 |
| - csharp: |
34 |
| - - 'csharp/**' |
35 |
| - php: |
36 |
| - - 'php/**' |
37 |
| - rust: |
38 |
| - - 'rust/**' |
39 |
| - python: |
40 |
| - - 'python/**' |
41 |
| - nodejs: |
42 |
| - - 'nodejs/**' |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - name: Get changed files (Push/Pull Request) |
| 26 | + id: changed_files |
| 27 | + env: |
| 28 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + run: | |
| 30 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 31 | + PR_NUMBER=${{ github.event.pull_request.number }} |
| 32 | + REPO_OWNER=${{ github.repository_owner }} |
| 33 | + REPO_NAME=${{ github.event.repository.name }} |
| 34 | +
|
| 35 | + # calling GitHub API for changed files in PR |
| 36 | + CHANGED_FILES=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 37 | + "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/files" | \ |
| 38 | + jq -r '.[].filename' | tr '\n' ' ') |
| 39 | + else |
| 40 | + CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD) |
| 41 | + fi |
| 42 | + echo "::set-output name=files::$CHANGED_FILES" |
| 43 | +
|
| 44 | + - name: Check Java changes |
| 45 | + id: java |
| 46 | + run: | |
| 47 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^(java/|pom.xml)'; then |
| 48 | + echo "::set-output name=java::true" |
| 49 | + else |
| 50 | + echo "::set-output name=java::false" |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Check C++ changes |
| 54 | + id: cpp |
| 55 | + run: | |
| 56 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^cpp/'; then |
| 57 | + echo "::set-output name=cpp::true" |
| 58 | + else |
| 59 | + echo "::set-output name=cpp::false" |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Check Golang changes |
| 63 | + id: golang |
| 64 | + run: | |
| 65 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^golang/'; then |
| 66 | + echo "::set-output name=golang::true" |
| 67 | + else |
| 68 | + echo "::set-output name=golang::false" |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Check C# changes |
| 72 | + id: csharp |
| 73 | + run: | |
| 74 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^csharp/'; then |
| 75 | + echo "::set-output name=csharp::true" |
| 76 | + else |
| 77 | + echo "::set-output name=csharp::false" |
| 78 | + fi |
| 79 | +
|
| 80 | + - name: Check PHP changes |
| 81 | + id: php |
| 82 | + run: | |
| 83 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^php/'; then |
| 84 | + echo "::set-output name=php::true" |
| 85 | + else |
| 86 | + echo "::set-output name=php::false" |
| 87 | + fi |
| 88 | +
|
| 89 | + - name: Check Rust changes |
| 90 | + id: rust |
| 91 | + run: | |
| 92 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^rust/'; then |
| 93 | + echo "::set-output name=rust::true" |
| 94 | + else |
| 95 | + echo "::set-output name=rust::false" |
| 96 | + fi |
| 97 | +
|
| 98 | + - name: Check Python changes |
| 99 | + id: python |
| 100 | + run: | |
| 101 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^python/'; then |
| 102 | + echo "::set-output name=python::true" |
| 103 | + else |
| 104 | + echo "::set-output name=python::false" |
| 105 | + fi |
| 106 | +
|
| 107 | + - name: Check Node.js changes |
| 108 | + id: nodejs |
| 109 | + run: | |
| 110 | + if echo "${{ steps.changed_files.outputs.files }}" | grep -qE '^nodejs/'; then |
| 111 | + echo "::set-output name=nodejs::true" |
| 112 | + else |
| 113 | + echo "::set-output name=nodejs::false" |
| 114 | + fi |
43 | 115 | java-build:
|
44 | 116 | needs: [paths-filter]
|
45 | 117 | if: ${{ needs.paths-filter.outputs.java == 'true' }}
|
|
0 commit comments