|
18 | 18 | pull_request:
|
19 | 19 |
|
20 | 20 | env:
|
21 |
| - HEAD_REF: ${{ github.head_ref }} |
22 | 21 | REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
|
23 | 22 | GITHUB_REPOSITORY: ${{ github.repository }}
|
24 |
| - |
25 | 23 | jobs:
|
26 | 24 | library_generation:
|
27 | 25 | runs-on: ubuntu-latest
|
28 | 26 | steps:
|
| 27 | + - name: Determine whether the pull request comes from a fork |
| 28 | + run: | |
| 29 | + if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then |
| 30 | + echo "This PR comes from a fork. Skip library generation." |
| 31 | + echo "SHOULD_RUN=false" >> $GITHUB_ENV |
| 32 | + else |
| 33 | + echo "SHOULD_RUN=true" >> $GITHUB_ENV |
| 34 | + fi |
29 | 35 | - uses: actions/checkout@v4
|
| 36 | + if: env.SHOULD_RUN == 'true' |
30 | 37 | with:
|
31 | 38 | fetch-depth: 0
|
32 | 39 | token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
|
33 |
| - - name: Generate changed libraries |
34 |
| - shell: bash |
35 |
| - run: | |
36 |
| - set -ex |
37 |
| - if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then |
38 |
| - echo "This PR comes from a fork. Generation will be skipped" |
39 |
| - exit 0 |
40 |
| - fi |
41 |
| - [ -z "$(git config user.email)" ] && git config --global user.email "[email protected]" |
42 |
| - [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" |
43 |
| - bash .github/scripts/hermetic_library_generation.sh \ |
44 |
| - --target_branch ${{ github.base_ref }} \ |
45 |
| - --current_branch $HEAD_REF |
46 |
| - env: |
47 |
| - GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} |
| 40 | + - uses: googleapis/sdk-platform-java/.github/[email protected] |
| 41 | + if: env.SHOULD_RUN == 'true' |
| 42 | + with: |
| 43 | + base_ref: ${{ github.base_ref }} |
| 44 | + head_ref: ${{ github.head_ref }} |
| 45 | + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} |
0 commit comments