From ea90b0042ce2a6c119f3afa0116db7e71f5d251a Mon Sep 17 00:00:00 2001 From: Hassan Arslan Date: Sun, 28 Jun 2026 18:22:52 +0300 Subject: [PATCH] fix(ci): publish-blog-draft draft detection (fetch base.sha; squash-safe) --- .github/workflows/publish-blog-draft.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-blog-draft.yml b/.github/workflows/publish-blog-draft.yml index ed17def..13ddeb1 100644 --- a/.github/workflows/publish-blog-draft.yml +++ b/.github/workflows/publish-blog-draft.yml @@ -18,6 +18,7 @@ jobs: - uses: actions/checkout@v4 with: ref: main + fetch-depth: 0 # full history so base.sha is present for the draft diff token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-node@v4 @@ -27,8 +28,12 @@ jobs: - name: Find draft files merged by this PR id: find_drafts run: | - git fetch origin ${{ github.event.pull_request.head.sha }} --depth=2 - FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ + BASE='${{ github.event.pull_request.base.sha }}' + HEAD='${{ github.event.pull_request.head.sha }}' + # fetch-depth:0 gives BASE via main history; fetch HEAD explicitly in case + # of a squash-merge where the PR head commit isn't reachable from main. + git fetch --no-tags origin "$HEAD" 2>/dev/null || true + FILES=$(git diff --name-only --diff-filter=AM "$BASE" "$HEAD" 2>/dev/null \ | grep '^docs/content-pipeline/drafts/.*\.md$' || true) echo "drafts<> $GITHUB_OUTPUT echo "$FILES" >> $GITHUB_OUTPUT