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