Documentation Publish #333
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
# Copyright (c) 2021-2022 TiaC Systems | |
# Copyright (c) 2021 Li-Pro.Net | |
# SPDX-License-Identifier: Apache-2.0 | |
name: Documentation Publish | |
on: | |
workflow_run: | |
workflows: ["Documentation Build", "Documentation Remove"] | |
types: [completed] | |
jobs: | |
doc-publish: | |
name: Publish archived documentation actions from artifacts | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Download artifact | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "doc" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/doc.zip', Buffer.from(download.data)); | |
- name: Upload documentation | |
env: | |
HOST: ${{ secrets.TSN_BRIDLE_DOCROOT_HOST }} | |
PORT: ${{ secrets.TSN_BRIDLE_DOCROOT_PORT }} | |
USER: ${{ secrets.TSN_BRIDLE_DOCROOT_USER }} | |
KEY: ${{ secrets.TSN_BRIDLE_DOCROOT_KEY }} | |
INBOX: ${{ secrets.TSN_BRIDLE_DOCROOT_INBOX }} | |
run: | | |
unzip doc.zip | |
mkdir -p ~/.ssh && \ | |
ssh-keyscan -p ${PORT} ${HOST} >> ~/.ssh/known_hosts | |
touch ~/.ssh/private && \ | |
chmod 600 ~/.ssh/private && \ | |
echo -e "${KEY}" > ~/.ssh/private | |
# Don't upload the archive and workflow metadata | |
files=$(ls -I doc.zip -I pr.txt) | |
for file in ${files}; do | |
scp -i ~/.ssh/private "${file}" "scp://${USER}@${HOST}:${PORT}/${INBOX}/${file}" | |
done | |
- name: Add preview URL comment for PRs | |
uses: carlescufi/action-doc-url@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
urlroot: ${{ secrets.TSN_BRIDLE_GHPR_URL_ROOT }} | |
pr-prefix: "PR-" | |
pr-file: pr.txt | |
continue-on-error: true |