Enhance icon generation script and PR workflow to utilize PR-specific repository and SHA, improving accuracy for forked repositories.
This commit is contained in:
parent
69e0b696fb
commit
3c47dab3ed
|
|
@ -44,8 +44,9 @@ function getAddedIconsFromMain() {
|
||||||
|
|
||||||
// Get GitHub raw file URL for icon
|
// Get GitHub raw file URL for icon
|
||||||
function getIconRawUrl(iconPath) {
|
function getIconRawUrl(iconPath) {
|
||||||
const repo = process.env.GITHUB_REPOSITORY || 'tabler/tabler-icons'
|
// Use PR repo and SHA if available (for forks), otherwise fallback to current repo
|
||||||
const ref = process.env.GITHUB_HEAD_REF || process.env.GITHUB_SHA || 'main'
|
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}`
|
return `https://raw.githubusercontent.com/${repo}/${ref}/icons/${iconPath}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,16 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Set base branch
|
- name: Set base branch and PR info
|
||||||
run: |
|
run: |
|
||||||
BASE_REF="${{ github.event.pull_request.base.ref }}"
|
BASE_REF="${{ github.event.pull_request.base.ref }}"
|
||||||
BASE_SHA="${{ github.event.pull_request.base.sha }}"
|
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_REF=${BASE_REF}" >> $GITHUB_ENV
|
||||||
echo "BASE_SHA=${BASE_SHA}" >> $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
|
# Fetch base branch to ensure it's available
|
||||||
git fetch origin ${BASE_REF}:${BASE_REF} || true
|
git fetch origin ${BASE_REF}:${BASE_REF} || true
|
||||||
|
|
||||||
|
|
@ -84,6 +88,8 @@ jobs:
|
||||||
env:
|
env:
|
||||||
BASE_REF: ${{ env.BASE_REF }}
|
BASE_REF: ${{ env.BASE_REF }}
|
||||||
BASE_SHA: ${{ env.BASE_SHA }}
|
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
|
run: pnpm run --silent generate-icons-comment > ./comment-icons.md || true
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue