Skip to content

Commit 90811b6

Browse files
authored
chore: change if condition in workflow (#1567)
* chore: change if condition in workflow * add head_ref * add var
1 parent 8d3af32 commit 90811b6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/hermetic_library_generation.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,37 @@ on:
1818
pull_request:
1919

2020
env:
21-
HEAD_REF: ${{ github.head_ref }}
2221
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
22+
GITHUB_REPOSITORY: ${{ github.repository }}
2323

2424
jobs:
2525
library_generation:
26-
# skip pull requests coming from a forked repository
27-
if: github.env.REPO_FULL_NAME == github.repository
2826
runs-on: ubuntu-latest
2927
steps:
28+
- name: Determine whether the pull request comes from a fork
29+
run: |
30+
if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then
31+
echo "This PR comes from a fork. Skip library generation."
32+
echo "SHOULD_RUN=false" >> $GITHUB_ENV
33+
else
34+
echo "SHOULD_RUN=true" >> $GITHUB_ENV
35+
fi
3036
- uses: actions/checkout@v4
37+
if: env.SHOULD_RUN == 'true'
3138
with:
3239
fetch-depth: 0
3340
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
3441
- name: Generate changed libraries
42+
if: env.SHOULD_RUN == 'true'
3543
shell: bash
3644
run: |
3745
set -ex
3846
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
3947
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
4048
bash .github/scripts/hermetic_library_generation.sh \
41-
--target_branch ${{ github.base_ref }} \
42-
--current_branch $HEAD_REF
49+
--target_branch "${BASE_REF}" \
50+
--current_branch "${HEAD_REF}"
4351
env:
52+
BASE_REF: ${{ github.base_ref }}
53+
HEAD_REF: ${{ github.head_ref }}
4454
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}

0 commit comments

Comments
 (0)