Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Publish documentation to Zoomin #330

Publish documentation to Zoomin

Publish documentation to Zoomin #330

name: Publish documentation to Zoomin
on:
workflow_dispatch:
inputs:
name:
description: Artifact name to be published to Zoomin
required: true
version:
description: If provided, the version will be appended to the title
required: false
permissions:
contents: write
jobs:
publish:
name: Publish the documentation
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Download artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DOWNLOAD_DIR=$(openssl rand -hex 8)
echo "DOWNLOAD_DIR=${DOWNLOAD_DIR}" >> $GITHUB_ENV
gh run download --name ${{ github.event.inputs.name }} --dir "${DOWNLOAD_DIR}"
- name: Install dependencies
run: |
sudo apt install -y sshpass
- name: Generate Zoomin tags.yml
env:
ZOOMIN_TITLE: ${{ vars.ZOOMIN_TITLE || 'nrf-asset-tracker' }}
ZOOMIN_DOCS_VERSION: ${{ github.event.inputs.version || 'unknown' }}
run: |
NORMALIZED_ZOOMIN_TITLE=${ZOOMIN_TITLE// /_}
NORMALIZED_DOCS_VERSION=${ZOOMIN_DOCS_VERSION// /_}
cd ${{ env.DOWNLOAD_DIR }}
echo "# Document tags for Zoomin.
# Tags for all topics:
mapping_global:
- ${NORMALIZED_ZOOMIN_TITLE}
- ${NORMALIZED_ZOOMIN_TITLE}-${NORMALIZED_DOCS_VERSION}
- cluster-nrf-at-${NORMALIZED_DOCS_VERSION}
# Tags for individual topics:
mapping_topics:
- docs/*.html: [\"applications\"]
- docs/*/*.html: [\"applications\"]
- docs/*/*/*.html: [\"applications\"]" > tags.yml
echo "tags.yml"
cat tags.yml
- name: Generate Zoomin custom.properties
env:
ZOOMIN_TITLE: ${{ vars.ZOOMIN_TITLE || 'nrf-asset-tracker' }}
ZOOMIN_BOOK_TITLE:
${{ vars.ZOOMIN_BOOK_TITLE || 'nRF Asset Tracker' }}
ZOOMIN_DOCS_VERSION: ${{ github.event.inputs.version }}
run: |
[[ -n "$ZOOMIN_DOCS_VERSION" ]] && ZOOMIN_TITLE="${ZOOMIN_TITLE}-${ZOOMIN_DOCS_VERSION}"
[[ -n "$ZOOMIN_DOCS_VERSION" ]] && ZOOMIN_BOOK_TITLE="${ZOOMIN_BOOK_TITLE} ${ZOOMIN_DOCS_VERSION}"
NORMALIZED_ZOOMIN_TITLE=${ZOOMIN_TITLE// /_}
cd ${{ env.DOWNLOAD_DIR }}
touch custom.properties
echo "manual.name=${NORMALIZED_ZOOMIN_TITLE}" >> custom.properties
echo "booktitle=${ZOOMIN_BOOK_TITLE}" >> custom.properties
echo "custom.properties"
cat custom.properties
- name: Compress Zoomin documentation
run: |
cd ${{ env.DOWNLOAD_DIR }}
ZIP_FILENAME=${{ github.workspace }}/zoomin_nrf_asset_tracker_${{ github.sha }}.zip
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV
zip -r -q "${ZIP_FILENAME}" .
- name: Upload Zoomin documentation
env:
ZOOMIN_SFTP_SERVER:
${{ vars.ZOOMIN_SFTP_SERVER || 'upload-v1.zoominsoftware.io' }}
ZOOMIN_SFTP_PATH:
${{ vars.ZOOMIN_SFTP_PATH ||
'/home/sftp/nordic/nordic-be-dev.zoominsoftware.io/sphinx-html/incoming'
}}
run: |
# Trust server
mkdir ~/.ssh
ssh-keyscan ${ZOOMIN_SFTP_SERVER} >> ~/.ssh/known_hosts
# Prepare key
echo "${{ secrets.ZOOMIN_KEY }}" | base64 -d > zoomin_key
chmod 600 zoomin_key
# Upload to Zoomin
sftp -v -i zoomin_key nordic@${ZOOMIN_SFTP_SERVER} <<EOF
cd ${ZOOMIN_SFTP_PATH}
put ${{ env.ZIP_FILENAME }}
quit
EOF