Documentation Publish #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Documentation Publish | |
on: | |
workflow_run: | |
workflows: ["Documentation Build"] | |
types: | |
- completed | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v2 | |
- name: Download artifacts | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: docbuild.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
name: cache | |
path: cache | |
- name: Install dependencies | |
run: | | |
sudo apt install -y sshpass | |
pip3 install -r scripts/requirements-doc.txt | |
- name: Upload cache files | |
env: | |
NCS_CACHE_AZ_KEY: ${{ secrets.NCS_CACHE_AZ_KEY }} | |
run: | | |
python3 doc/_scripts/cache_upload.py -i cache | |
- name: Prepare documentation upload | |
working-directory: cache | |
run: | | |
# decompress cache files | |
for f in *.zip; do | |
unzip "$f" | |
done | |
# compress HTML files | |
mkdir upload && cd upload | |
mv ../extra/index.html ../html | |
mv ../extra/versions.json ../html | |
tar -C ../html -zcf "doc_build_${GITHUB_RUN_ID}.tgz" . | |
# prepare request file | |
mv ../extra/monitor.txt monitor_${GITHUB_RUN_ID}.txt | |
sed -i "s/__FILE__/doc_build_${GITHUB_RUN_ID}.tgz/g" monitor_${GITHUB_RUN_ID}.txt | |
- name: Upload documentation | |
env: | |
SSHUSER: ${{ secrets.NCS_TRANSFER_DOC_USR }} | |
SSHPASS: ${{ secrets.NCS_TRANSFER_DOC_PWD }} | |
working-directory: cache/upload | |
run: | | |
# trust server | |
mkdir -p ~/.ssh && \ | |
ssh-keyscan -p 2222 transfer.nordicsemi.no >> ~/.ssh/known_hosts | |
# upload files | |
for file in *; do | |
echo "put ${file}" | \ | |
sshpass -e sftp -P 2222 -o BatchMode=no -b - [email protected] | |
done | |
- name: Add preview URL comment for PRs | |
uses: carlescufi/action-doc-url@main | |
with: | |
github-token: ${{ secrets.NCS_GITHUB_TOKEN }} | |
urlroot: ${{ secrets.NCS_DOC_URL_ROOT }} | |
pr-prefix: "PR-" | |
pr-file: cache/extra/pr.txt |