Skip to content

Commit 9d0b5c4

Browse files
committed
chore: use composite action
1 parent 04c5435 commit 9d0b5c4

File tree

2 files changed

+18
-130
lines changed

2 files changed

+18
-130
lines changed

.github/scripts/hermetic_library_generation.sh

Lines changed: 0 additions & 117 deletions
This file was deleted.

.github/workflows/hermetic_library_generation.yaml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,29 @@ name: Hermetic library generation upon generation config change through pull req
1717
on:
1818
pull_request:
1919

20+
env:
21+
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
22+
GITHUB_REPOSITORY: ${{ github.repository }}
2023
jobs:
2124
library_generation:
22-
# skip pull requests come from a forked repository
23-
if: github.event.pull_request.head.repo.full_name == github.repository
2425
runs-on: ubuntu-latest
2526
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
2635
- uses: actions/checkout@v4
36+
if: env.SHOULD_RUN == 'true'
2737
with:
2838
fetch-depth: 0
2939
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
30-
- name: Generate changed libraries
31-
shell: bash
32-
run: |
33-
set -x
34-
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
35-
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
36-
bash .github/scripts/hermetic_library_generation.sh \
37-
--target_branch ${{ github.base_ref }} \
38-
--current_branch ${{ github.head_ref }}
39-
env:
40-
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

Comments
 (0)