@@ -471,6 +471,72 @@ jobs:
471471 with :
472472 name : release-html
473473 path : html.tar.gz
474+ public-docs :
475+ name : Publish docs
476+ # Run only when:
477+ # * We push to a branch
478+ # * If the target repository is apache/arrow-java:
479+ # * The target branch is main
480+ # * Else (fork repositories):
481+ # * All branches
482+ if : >-
483+ github.event_name == 'push' &&
484+ github.ref_type == 'branch' &&
485+ ((github.repository == 'apache/arrow-java' && github.ref_name == 'main') ||
486+ github.repository != 'apache/arrow-java')
487+ needs :
488+ - docs
489+ runs-on : ubuntu-latest
490+ permissions :
491+ contents : write
492+ steps :
493+ - name : Checkout
494+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
495+ with :
496+ path : site
497+ persist-credentials : true
498+ - name : Prepare branch
499+ run : |
500+ if [ "${GITHUB_REPOSITORY}" = "apache/arrow-java" ]; then
501+ BRANCH=asf-site
502+ else
503+ BRANCH=gh-pages
504+ fi
505+ echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV}
506+
507+ cp site/.asf.yaml ./
508+ cd site
509+ git fetch
510+ if ! git switch -c "${BRANCH}" "origin/${BRANCH}"; then
511+ git switch --orphan "${BRANCH}"
512+ fi
513+ touch .nojekyll
514+ cp ../.asf.yaml ./
515+ git add .nojekyll .asf.yaml
516+ - name : Download
517+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
518+ with :
519+ name : release-html
520+ - name : Extract
521+ run : |
522+ tar -xf html.tar.gz
523+ rm -rf site/main
524+ mv html site/main
525+ git -C site add main
526+ if [ "$(git status --prcelain)" == "" ]; then
527+ NEED_PUSH=true
528+ else
529+ NEED_PUSH=false
530+ fi
531+ echo "NEED_PUSH=${NEED_PUSH}" >> ${GITHUB_ENV}
532+ - name : Push
533+ if : env.NEED_PUSH == 'true'
534+ run : |
535+ cd site
536+ git config --global user.name 'github-actions[bot]'
537+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
538+ git commit -m "Publish documentation (${GITHUB_SHA})"
539+ git push origin "${BRANCH}"
474540 verify :
475541 name : Verify
476542 needs :
0 commit comments