Skip to content

Commit

Permalink
chore: fix hermetic_library_generation fork check
Browse files Browse the repository at this point in the history
This inlines the `repo.full_name` as an env var when checking if the PR is coming from a fork in order to prevent script injections.

The current state doesn't work properly because `github.env` cannot be accessed in the `if` statement.
  • Loading branch information
diegomarquezp authored Sep 5, 2024
1 parent 5f61fe1 commit 4d4d596
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ on:
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:
- uses: actions/checkout@v4
Expand All @@ -35,6 +34,10 @@ jobs:
shell: bash
run: |
set -ex
if [[ "${GITHUB_REPOSITORY}" != "${REPO_FULL_NAME}" ]]; then
echo "This PR comes from a fork. Generation will be skipped"
exit 0
fi
[ -z "$(git config user.email)" ] && git config --global user.email "[email protected]"
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
bash .github/scripts/hermetic_library_generation.sh \
Expand Down

0 comments on commit 4d4d596

Please sign in to comment.