diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5e1870ca..75a56e432 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,7 @@ jobs: uses: ./.github/workflows/frontend-build.yml with: node_version: '24.x' + pull_number: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || '' }} apphost-build: needs: changes diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml index d83b8f7b1..2a8c67d39 100644 --- a/.github/workflows/frontend-build.yml +++ b/.github/workflows/frontend-build.yml @@ -8,6 +8,11 @@ on: required: true default: "24.x" type: string + pull_number: + description: Pull request number when available + required: false + default: "" + type: string permissions: contents: read @@ -25,7 +30,27 @@ jobs: fetch-depth: 0 - name: Ensure full git history for Lunaria - run: git fetch --unshallow 2>/dev/null || true + env: + PULL_NUMBER: ${{ inputs.pull_number }} + run: | + if [ -n "$PULL_NUMBER" ]; then + case "$PULL_NUMBER" in + (*[!0-9]*) + echo "Invalid pull_number input: '$PULL_NUMBER'" >&2 + exit 1 + ;; + esac + + pull_ref="+refs/pull/${PULL_NUMBER}/head:refs/remotes/origin/pull/${PULL_NUMBER}/head" + + if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then + git fetch origin "$pull_ref" --unshallow + else + git fetch origin "$pull_ref" + fi + elif [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then + git fetch --unshallow + fi - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 with: