From da1338f71ef2f5b0c0690fb6a013244f7fce00f9 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 11 Sep 2024 11:23:10 -0400 Subject: [PATCH 1/3] chore: change if condition in workflow --- .github/workflows/hermetic_library_generation.yaml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index ab23b9fec..0fc0b8099 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -18,20 +18,28 @@ on: pull_request: env: - HEAD_REF: ${{ github.head_ref }} REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }} + GITHUB_REPOSITORY: ${{ github.repository }} jobs: library_generation: - # skip pull requests coming from a forked repository - if: github.env.REPO_FULL_NAME == github.repository runs-on: ubuntu-latest steps: + - name: Determine whether the pull request comes from a fork + run: | + if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then + echo "This PR comes from a fork. Skip library generation." + echo "SHOULD_RUN=false" >> $GITHUB_ENV + else + echo "SHOULD_RUN=true" >> $GITHUB_ENV + fi - uses: actions/checkout@v4 + if: env.SHOULD_RUN == 'true' with: fetch-depth: 0 token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} - name: Generate changed libraries + if: env.SHOULD_RUN == 'true' shell: bash run: | set -ex From d11e328fb7dd5707e609fc1a7e12371d35599395 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 11 Sep 2024 11:27:14 -0400 Subject: [PATCH 2/3] add head_ref --- .github/workflows/hermetic_library_generation.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index 0fc0b8099..b82dd92c7 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -49,4 +49,6 @@ jobs: --target_branch ${{ github.base_ref }} \ --current_branch $HEAD_REF env: + BASE_REF: ${{ github.base_ref }} + HEAD_REF: ${{ github.head_ref }} GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} From 50ae9b2d6fba40d838bb5a6d2399d0c2a4bb56d7 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 11 Sep 2024 11:27:59 -0400 Subject: [PATCH 3/3] add var --- .github/workflows/hermetic_library_generation.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index b82dd92c7..0266fbc96 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -46,8 +46,8 @@ jobs: [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" bash .github/scripts/hermetic_library_generation.sh \ - --target_branch ${{ github.base_ref }} \ - --current_branch $HEAD_REF + --target_branch "${BASE_REF}" \ + --current_branch "${HEAD_REF}" env: BASE_REF: ${{ github.base_ref }} HEAD_REF: ${{ github.head_ref }}