Skip to content

Commit bed8c8c

Browse files
kopporclaude
andcommitted
Publish snapshot for same-repo pull requests
Fork PRs cannot publish (no secrets), and branches behind main would push a snapshot missing commits already on main, so both are skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01159RbWmMUr4KQrDuxGBPx9
1 parent 511b8fb commit bed8c8c

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
pull_request:
78
workflow_dispatch:
89

910
permissions:
@@ -16,11 +17,26 @@ concurrency:
1617
jobs:
1718
publish:
1819
runs-on: ubuntu-latest
19-
if: github.repository == 'JabRef/html-to-node'
20+
# Fork PRs get no secrets, so they can never publish - don't even start the job for them
21+
if: github.repository == 'JabRef/html-to-node' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
2022
steps:
2123
- uses: actions/checkout@v7
2224
with:
2325
show-progress: 'false'
26+
# Publish the branch as-is, not GitHub's main-merged ref, and keep enough
27+
# history for the is-up-to-date check below
28+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
29+
fetch-depth: 0
30+
- name: Skip if branch is behind main
31+
id: uptodate
32+
# A stale branch would publish a snapshot missing commits that are already on
33+
# main, silently downgrading the artifact for everyone consuming it
34+
run: |
35+
git fetch --no-tags origin main
36+
if [ "${{ github.event_name }}" = "pull_request" ] && ! git merge-base --is-ancestor FETCH_HEAD HEAD; then
37+
echo "Branch is behind main - rebase/merge main before a snapshot is published."
38+
echo "skip=true" >> "$GITHUB_OUTPUT"
39+
fi
2440
- name: Setup JDK
2541
uses: actions/setup-java@v5
2642
with:
@@ -45,6 +61,7 @@ jobs:
4561
mavenCentralPassword=${{ secrets.KOPPOR_MAVENCENTRALPASSWORD }}
4662
EOF
4763
- name: Publish snapshot
64+
if: steps.uptodate.outputs.skip != 'true'
4865
# Release versions are published by release.yml on tag push; this workflow only
4966
# handles the rolling snapshot
5067
run: |

0 commit comments

Comments
 (0)