|
16 | 16 | name: Hermetic library generation upon generation config change through pull requests |
17 | 17 | on: |
18 | 18 | pull_request: |
19 | | - paths: |
20 | | - - 'generation_config.yaml' |
21 | | - - '.readme-partials.yaml' |
22 | | - - 'owlbot.py' |
23 | | - - 'versions.txt' |
24 | | - - '.github/.OwlBot-hermetic.yaml' |
25 | 19 |
|
26 | 20 | env: |
27 | 21 | REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }} |
|
43 | 37 | with: |
44 | 38 | fetch-depth: 0 |
45 | 39 | token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} |
| 40 | + - name: is applicable |
| 41 | + env: |
| 42 | + # set our branch names to be the names in the "origin" remote since we aren't actually checking these branches out |
| 43 | + base_ref: origin/${{ github.base_ref }} |
| 44 | + head_ref: origin/${{ github.head_ref }} |
| 45 | + run: | |
| 46 | + #!/bin/bash -x |
| 47 | + |
| 48 | + # verify we have refs so error messages are clearer |
| 49 | + git rev-parse --verify "$base_ref" |
| 50 | + git rev-parse --verify "$head_ref" |
| 51 | + |
| 52 | + # list all paths that are changed between before and after |
| 53 | + changed_paths=$(git diff --name-only "$base_ref" "$head_ref") |
| 54 | + |
| 55 | + # define our array of paths that are included |
| 56 | + include_list=() |
| 57 | + |
| 58 | + # push our include regex values onto the array |
| 59 | + include_list+=("^.github/workflows/hermetic_library_generation.yaml$") |
| 60 | + include_list+=("^generation_config.yaml$") |
| 61 | + include_list+=("^.readme-partials.yaml$") |
| 62 | + include_list+=("^owlbot.py$") |
| 63 | + include_list+=("^versions.txt$") |
| 64 | + include_list+=("^.github/.OwlBot-hermetic.yaml$") |
| 65 | + |
| 66 | + # join all the paths into a single regex |
| 67 | + pattern="$(IFS=$'|' ; echo "${include_list[*]}")" |
| 68 | + |
| 69 | + # check if we have any paths that match our include list |
| 70 | + match=0 |
| 71 | + echo -e "${changed_paths}" | grep -E "${pattern}" 2>&1 || match=1 |
| 72 | + |
| 73 | + if [[ $match == 0 ]]; then |
| 74 | + echo "SHOULD_RUN=true" >> $GITHUB_ENV |
| 75 | + else |
| 76 | + echo "This PR does not match the include list" |
| 77 | + echo "SHOULD_RUN=false" >> $GITHUB_ENV |
| 78 | + fi |
| 79 | +
|
46 | 80 | - uses: googleapis/sdk-platform-java/.github/[email protected] |
47 | 81 | if: env.SHOULD_RUN == 'true' |
48 | 82 | with: |
|
0 commit comments