From 3c47dab3ed3eb0621f42db7e21ff77f45ebe58de Mon Sep 17 00:00:00 2001 From: codecalm Date: Tue, 23 Dec 2025 02:33:39 +0100 Subject: [PATCH] Enhance icon generation script and PR workflow to utilize PR-specific repository and SHA, improving accuracy for forked repositories. --- .build/generate-icons-comment.mjs | 5 +++-- .github/workflows/validate-pr.yml | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.build/generate-icons-comment.mjs b/.build/generate-icons-comment.mjs index 5c26730c9..d0dafa898 100644 --- a/.build/generate-icons-comment.mjs +++ b/.build/generate-icons-comment.mjs @@ -44,8 +44,9 @@ function getAddedIconsFromMain() { // Get GitHub raw file URL for icon function getIconRawUrl(iconPath) { - const repo = process.env.GITHUB_REPOSITORY || 'tabler/tabler-icons' - const ref = process.env.GITHUB_HEAD_REF || process.env.GITHUB_SHA || 'main' + // Use PR repo and SHA if available (for forks), otherwise fallback to current repo + const repo = process.env.PR_REPO || process.env.GITHUB_REPOSITORY || 'tabler/tabler-icons' + const ref = process.env.PR_SHA || process.env.GITHUB_SHA || 'main' return `https://raw.githubusercontent.com/${repo}/${ref}/icons/${iconPath}` } diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index a471aec76..3033101c6 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -18,12 +18,16 @@ jobs: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - - name: Set base branch + - name: Set base branch and PR info run: | BASE_REF="${{ github.event.pull_request.base.ref }}" BASE_SHA="${{ github.event.pull_request.base.sha }}" + PR_REPO="${{ github.event.pull_request.head.repo.full_name }}" + PR_SHA="${{ github.event.pull_request.head.sha }}" echo "BASE_REF=${BASE_REF}" >> $GITHUB_ENV echo "BASE_SHA=${BASE_SHA}" >> $GITHUB_ENV + echo "PR_REPO=${PR_REPO}" >> $GITHUB_ENV + echo "PR_SHA=${PR_SHA}" >> $GITHUB_ENV # Fetch base branch to ensure it's available git fetch origin ${BASE_REF}:${BASE_REF} || true @@ -84,6 +88,8 @@ jobs: env: BASE_REF: ${{ env.BASE_REF }} BASE_SHA: ${{ env.BASE_SHA }} + PR_REPO: ${{ env.PR_REPO }} + PR_SHA: ${{ env.PR_SHA }} run: pnpm run --silent generate-icons-comment > ./comment-icons.md || true continue-on-error: true