Skip to content

Commit

Permalink
CI job to publish docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Dec 18, 2023
1 parent 35bafae commit 9e3e879
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/actions/sync-nightlies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Based on Apache Arrow's sync-nightlies action
# https://github.com/apache/arrow/blob/master/.github/actions/sync-nightlies/action.yml
name: 'Sync Nightlies'
description: 'Sync files to and from nightlies.apache.org'
inputs:
upload:
description: 'Sync from local to remote'
default: false
required: false
switches:
description: 'see rsync --help'
required: true
local_path:
description: 'The relative local path within $GITHUB_WORKSPACE'
required: true
remote_path:
description: 'The remote path incl. sub dirs e.g. {{secrets.path}}/arrow/r'
required: true
remote_host:
description: 'The remote host'
required: true
remote_port:
description: 'The remote port'
required: false
default: 22
remote_user:
description: 'The remote user'
required: true
remote_key:
description: 'The remote key'
required: true

runs:
using: "composite"
steps:
- name: Sync files
shell: bash
env:
SWITCHES: "${{ inputs.switches }}"
LOCAL_PATH: "${{ github.workspace }}/${{ inputs.local_path }}"

SSH_KEY: "${{ inputs.remote_key }}"
PORT: "${{ inputs.remote_port }}"
USER: "${{ inputs.remote_user }}"
HOST: "${{ inputs.remote_host }}"
REMOTE_PATH: "${{ inputs.remote_path }}"
run: |
# Make SSH key available and add remote to known hosts
eval "$(ssh-agent)" > /dev/null
echo "$SSH_KEY" | tr -d '\r' | ssh-add - >/dev/null
mkdir -p .ssh
chmod go-rwx .ssh
echo "$HOST_KEY" >> .ssh/known_hosts
# strict errors
set -eu
# We have to use a custom RSH to supply the port
RSH="ssh -o StrictHostKeyChecking=no -p $PORT"
DSN="$USER@$HOST"
# It is important to append '/' to the source path otherwise
# the entire source dir will be created as a sub dir in the destination
if [ "${{ inputs.upload }}" = true ]
then
SOURCE=$LOCAL_PATH/
DEST=$DSN:$REMOTE_PATH
else
SOURCE=$DSN:$REMOTE_PATH/
DEST=$LOCAL_PATH
fi
rsync $SWITCHES --rsh="$RSH" $SOURCE $DEST
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish docs

on:
workflow_dispatch:

jobs:
documentation:
name: Documentation with Paradox
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xms2G -Xmx2G -Xss2M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: Cache Coursier cache
uses: coursier/cache-action@v6

- name: "Create site with Paradox"
run: cd docs && sbt makeSite

# Create directory structure upfront since rsync does not create intermediate directories otherwise
- name: Create doc directory structure
run: |-
mkdir -p target/nightly-docs/docs/pekko-connectors-samples/${{ github.ref_name }}-snapshot/
mv docs/target/site/ target/nightly-docs/docs/pekko-connectors-samples/${{ github.ref_name }}-snapshot/docs
- name: Upload nightly docs
uses: ./.github/actions/sync-nightlies
with:
upload: true
switches: --archive --compress --update --delete --progress --relative
local_path: target/nightly-docs/./docs/pekko-connectors-samples/${{ github.ref_name }}-snapshot # The intermediate dot is to show `--relative` which paths to operate on
remote_path: ${{ secrets.NIGHTLIES_RSYNC_PATH }}/pekko/
remote_host: ${{ secrets.NIGHTLIES_RSYNC_HOST }}
remote_port: ${{ secrets.NIGHTLIES_RSYNC_PORT }}
remote_user: ${{ secrets.NIGHTLIES_RSYNC_USER }}
remote_key: ${{ secrets.NIGHTLIES_RSYNC_KEY }}

0 comments on commit 9e3e879

Please sign in to comment.