Documentation Publish #1
Workflow file for this run
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", "Documentation Remove"] | |
types: | |
- completed | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: 'Download artifact' | |
uses: actions/[email protected] | |
with: | |
script: | | |
var artifacts = await github.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.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: | |
SSHUSER: ${{ secrets.NCS_TRANSFER_DOC_USR }} | |
SSHPASS: ${{ secrets.NCS_TRANSFER_DOC_PWD }} | |
run: | | |
sudo apt install -y sshpass | |
unzip doc.zip | |
# Don't upload the archive and workflow metadata | |
files=$(ls -I doc.zip -I pr.txt) | |
mkdir -p ~/.ssh && \ | |
ssh-keyscan -p 2222 transfer.nordicsemi.no >> ~/.ssh/known_hosts | |
for file in $files; 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: pr.txt |