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