Skip to content

Commit 1e9c8ab

Browse files
chore: secure hermetic_library_generation workflow (#2317)
* chore: secure hermetic_library_generation workflow Thanks to @diogoteles08 for the inspection on our repos. This PR inlines environment variables to avoid overriding script injections. * fix github object reference * Update hermetic_library_generation.yaml * Update hermetic_library_generation.yaml * fix env reference * use vars instead of env * workaround for indirectly referencing env in jobs.if * rename job * test job without steps * cleaner no-op step * rewording * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * simplify conditional generation --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 78a19f0 commit 1e9c8ab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/hermetic_library_generation.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ on:
1919

2020
env:
2121
HEAD_REF: ${{ github.head_ref }}
22+
REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
23+
GITHUB_REPOSITORY: ${{ github.repository }}
2224

2325
jobs:
2426
library_generation:
25-
# skip pull requests come from a forked repository
26-
if: github.event.pull_request.head.repo.full_name == github.repository
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
@@ -34,6 +34,10 @@ jobs:
3434
shell: bash
3535
run: |
3636
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
3741
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
3842
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
3943
bash .github/scripts/hermetic_library_generation.sh \

0 commit comments

Comments
 (0)